GIAC
GSSP-JAVA · Question #121
Mark develops an application using Java language. He writes the following code snippet in the application. public class mClass{ public static void main(String args[]){ try{ return; }…
The correct answer is A. The code snippet will compile successfully and the output will be displayed as "Finally". See the full explanation below for the reasoning.
Question
Mark develops an application using Java language. He writes the following code snippet in the application. public class mClass{ public static void main(String args[]){ try{ return; } finally{System.out.print("Finally");}}} What will happen when Mark attempts to compile and execute the code snippet?
Options
- AThe code snippet will compile successfully and the output will be displayed as "Finally".
- BThe code snippet will compile successfully, but an exception message will be displayed at
- CA compile time error will occur because the catch block is not defined.
- DThe code snippet will compile successfully, but nothing will be displayed as output on
How the community answered
(27 responses)- A70% (19)
- B19% (5)
- C4% (1)
- D7% (2)
Community Discussion
No community discussion yet for this question.