Exceptions - Programming

Q1:

What will be the output of the program?
try 
{ 
    int x = 0; 
    int y = 5 / x; 
} 
catch (Exception e) 
{
    System.out.println('Exception'); 
} 
catch (ArithmeticException ae) 
{
    System.out.println(' Arithmetic Exception'); 
} 
System.out.println('finished');

A finished

B Exception

C Compilation fails.

D Arithmetic Exception

ANS:A - finished

Compilation fails because ArithmeticException has already been caught. ArithmeticException is a subclass of java.lang.Exception, by time the ArithmeticException has been specified it has already been caught by the Exception class.