Java | Exception Handling | Question 2
class Test extends Exception { } class Main { public static void main(String args[]) { try { throw new Test(); } catch (Test t) { System.out.println( "Got the Test Exception" ); } finally { System.out.println( "Inside finally block " ); } } } |
(A)
Got the Test Exception Inside finally block
(B)
Got the Test Exception
(C)
Inside finally block
(D) Compiler Error
Answer: (A)
Explanation: In Java, the finally is always executed after the try-catch block. This block can be used to do the common cleanup work. There is no such block in C++.
Quiz of this Question
Please Login to comment...