Question: Consider the following Java program. What will be the output when it is executed? public class ExceptionTest { public static void main ( String [
Consider the following Java program. What will be the output when it is executed?
public class ExceptionTest
public static void mainString args
try
System.out.printlnBefore throwing exception.";
throw new RuntimeExceptionDemo Exception";
catch RuntimeException e
System.out.printlnCaught a RuntimeException.";
catch Exception e
System.out.printlnCaught an Exception.";
finally
System.out.printlnFinally block executed.";
System.out.printlnAfter trycatchfinally.";
Before throwing exception.
Caught an Exception.
Finally block executed.
After trycatchfinally
Before throwing exception.
Caught a RuntimeException.
Finally block executed.
After trycatchfinally
Before throwing exception.
Caught an Exception.
Finally block executed.
Caught a RuntimeException.
Finally block executed.
After trycatchfinally.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
