Java OCA OCP Practice Question 1372

Question

Which of the following statements about try-catch blocks are correct? (Choose two.)

  • A. A catch block can never appear after a finally block.
  • B. A try block must be followed by a catch block.
  • C. A finally block can never appear after a catch block.
  • D. A try block must be followed by a finally block.
  • E. A try block can have zero or more catch blocks.
  • F. A try block can have zero or more finally blocks.


A, E.

Note

A try block can have zero or more catch blocks, and zero or one finally blocks, but must be accompanied by at least one of these blocks.

Options B, D, and F are incorrect, and Option E is correct.

A finally block must appear after the last catch block, if there are any, making Option C incorrect, and Option A correct.




PreviousNext

Related