Menu
Topics Index
...
`

Identify lines of code executed473


If you need explanation Read this topic

If you need Answer Take test on this topic

Identify lines of code executed473
What lines of the following program gets executed, given that the exception is thrown at LINE A.
try
{
    // LINE A
    try
    {
        // LINE B
    }
    catch(Exception ex)
    {
        // LINE C
    }
    // LINE D
}
catch(Exception e)
{
    // LINE E
    // LINE F
}
// LINE G

A. A, E, F, G
B. A, C, D, E, F, G
C. A, B, C, D, E, F, G
D. A, B, D, E, F, G
Topic: Try Catch Block In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is A.here  we have the exception handling concept where exception means runtime error which causes the abnormal trmination of the program...when exception  occurs system collect the info about the exception and throws the object..the process of handling those object is exception handling..we have some keywords here to use
Execution:

here we have nested try catch concept in certain situations we may need to represent some part of the code in otehr try block so in that kind of situations we use nested try-catch blocks..
* if the exception thorws at outer try than system will directly goes to outer catch for the handling by skipping remaining statements...so here exception throws at A so it will skip all b,c,d, lines enters into the catch and threre we have E,F those lines will execute next we have G outside try-cathch so it will excute..

*if the exeception raise in inner try block than 1st system enters inner catch and checks if it handles ok otherwise excetion throws back to the outer catch

Posted by Uday Kumar    2015-01-30 03:53:03


Ans is Option A.... here we are giving nested try-catch blocks if any exception occur in try block it will go to catch block Exception is an abnormal condition where compiler can not handle that situtation        if we get exception in LineA then it will go to outer catch block i.e Line E, Line F  will execute because if exception occur in outer try block then it will execute outer catch-block...  if exception occur in inner try block then it will execute outer catch-block... after that the Line G Will execute so Option A is Ans...

Posted by Bhagi Bhagyasri    2015-01-30 04:11:46


a.

Posted by Shubham Bansal    2015-01-30 05:58:17


ANS IS A (A E F G)

--Here,the concept of "NESTED TRY CATCH" is used.

--An exception is an event that occurs during the
execution of a program that disrupts the normal flow of
instructions.

--A method catches an exception using a combination of
the try and catch keywords. A try/catch block is placed
around the code that might generate an exception.
Code within a try/catch block is referred to as protected
code, and the syntax for using try/catch looks like the
following:

try
{
   //Protected code
}catch(ExceptionName e1)
{
   //Catch block
}

--Whenever Exception occurs in "TRY" block control will
move to appropriate "CATCH" block.

--IN above program,nested try catch is used.If Exception occurs in outer try block
at LINE A,then control will move to outer catch executing
lines E and F.

--When catch is executed,control will move out of it,
executing Line G.

Posted by Mânïshå Mùlchåndânï    2015-01-30 18:12:23


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Bhagi Bhagyasri,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Ganesh Kani. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-02-02 06:24:08


© meritcampus 2019

All Rights Reserved.

Open In App