Multiple choice

In which of the following cases will the finally block not be executed after the try block?

  1. If try block does not have any exceptions.

  2. If try block has a return statement.

  3. If exception is not handled in catch block.

  4. If try block has System.exit(0) statement.

  5. All of the above

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

If we have System.exit(0) statement in try block or in case of threads the thread is killed, finally block will not be executed.