Multiple choice

Which of the following is true about 'finally' in Java?

  1. There should be a catch block to execute finally clause.

  2. Finally block is executed only when there is an exception in a program.

  3. JVM always executes finally block before terminating the program.

  4. Finally block can be put before catch block.

  5. Finally block can handle the exception in the code.

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

JVM executes finally block just before terminating the program to close the connection and resources.