Java OCA OCP Practice Question 453

Question

Suppose a method called finallyTest() consists of a try block, followed by a catch block, followed by a finally block.

Assuming the JVM doesn't crash and the code does not execute a System.exit() call, under what circumstances will the finally block not begin to execute?

  • A. The try block throws an exception, and the catch block also throws an exception.
  • B. The try block throws an exception that is not handled by the catch block.
  • C. The try block throws an exception, and the catch block calls finallyTest() in a way that causes another exception to be thrown.
  • D. If the JVM doesn't crash and the code does not execute a System.exit() call, the finally block will always execute.


D.

Note

Unless execution terminates abnormally, the finally block will always eventually execute.




PreviousNext

Related