Java OCA OCP Practice Question 859

Question

Which of the following statements about a finally block is true?

  • A. Every line of the finally block will be executed.
  • B. The finally block is executed only if the related catch block is also executed.
  • C. The finally statement requires brackets {}.
  • D. The finally block cannot throw an exception.


C.

Note

A finally block can throw an exception, in which case not every line of the finally block would be executed.

Options A and D are incorrect.

Option B is incorrect.

The finally block is called regardless of whether or not the related catch block is executed. Option C is the correct answer.

A finally statement requires brackets {}.




PreviousNext

Related