Multiple choice

Which of the following statements regarding 'finally' block in Java is false?

  1. Before the termination of the program, JVM executes the 'finally' block (if any).

  2. The 'finally' block can be used for writing the cleanup code.

  3. The 'finally' block must be followed by try or catch block.

  4. There can be multiple 'finally' blocks for a try block.

  5. The 'finally' block is not executed if the program exists.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is a false statement. There can only be one finally block for each try block. Since the statement is false about 'finally' block in Java, it is the correct alternative.