class NewException extends Exception {}
class AnotherException extends Exception {}
public class A {
public static void main(
String[] args ) throws Exception
{
try
{
m2()
}
finally { m3() ; }
}
}
public static void m2() throw NewException { throw newException(); }
public static void m3() throw AnotherException { throw AnotherException(); }
ANS : It will compile but throw AnotherException when run
What i have understood :
Now m2() has no catch block, but as it declared in the throws clause, it is passed
to the default exception handler. The finally block will definitely get executed,
but will not be caught so as it is passed on to the default exception handler
it will at run-time give AnotherException .
Pls correct me if wrong .Can me someone explain the output .