Untitled Document

Subscribe here to get updates on new Videos

 

22. Control flow in try catch finally (Java Exception Handling) ?

 

 

 

previous homenext

 

Control Flow in try-catch-finally

try
{
start 1;
start 2;
start 3;
}
catch(x e)
{
start 4;
}
finally
{
start 5;
}
start 6;

Case 1:

If there is no exception

1,2,3,5,6 normal termination

Case 2:

If an exception raised at statement 2 and corresponding catch block matched

1,4,5,6 Normal termination

Case 3:

If an Exception raised at statement-2 and the corresponding catch block not matched

1,5 Abnormal Termination

Case 4:

If an Exception raised at statement-4 then it is always Abnormal termination but before Abnormal termination finally block will be executed.

Case 5:

If an Exception raised at statement-5 or at statement-6 then it is always Abnormal termination.