Q1: What will be the output of the program?
public class Foo 
    public static void main(String[] args) 
            System.out.println( 'Finally' ); 

A An exception is thrown at runtime.

B Finally

C Compilation fails.

D The code runs with no output.

ANS:A - Finally

If you put a finally block after a try and its associated catch blocks, then once execution enters the try block, the code in that finally block will definitely be executed except in the following circumstances:

  1. An exception arising in the finally block itself.
  2. The death of the thread.
  3. The use of System.exit()
  4. Turning off the power to the CPU.
I suppose the last three could be classified as VM shutdown.

img not found

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.