78 Program on Nested Try, Catch Finally Blocks in Java ?

Code:

class Demo
{
public static void main( String args[] )
{
try
{
System.out.println(" outer try block ");
int a = 10/0;
try
{
System.out.println(" inner try block ");
int b = 10/0;
}
catch( Exception e )
{
System.out.println("  inner catch block ");
}
finally
{
System.out.println(" inner finally block ");
}
}
catch( NegativeArraySizeException e )
{
System.out.println(" outer catch block ");
}
finally
{
System.out.println(" outer finally block ");
}
}
}


Output:


Previous
Next Post »