Exception Handling puzzle
Hi please pay close attention to this small code snippette.
As our rule says exception handling mechanism
The finally block always gets executed even if we are using the
return statements.
The code will return the OP as
30
public class TryCatchDemo {
static int giveInt()
{
try
{
return 10;
}
catch(Exception e)
{
return 20;
}
finally
{
return 30;
}
}
public static void main(String[] args) {
System.out.println(""+giveInt());
}
}
0 comments: