-
What is the output of this program?
public class Result
{
public static void main(String args[])
{
try
{
int num = 0;
int num0 = 23;
int num1 = num0 / num;
System.out.print(+num1);
}
catch(Exception e)
{
System.out.print("Interview Mania");
}
finally
{
System.out.print(" Finally executed...");
}
}
}
-
- Interview Mania
- Finally executed...
- Interview Mania Finally executed...
- All of above
- None of these
Correct Option: C
finally block is always executed after tryblock, no matter exception is found or not. catch block is executed only when exception is found. Here divide by zero exception is found hence both catch and finally are executed.