Java OCA OCP Practice Question 1047

Question

When are you required to use a finally block in a regular try statement (not a try-with-resources)?

  • A. Never.
  • B. When the program code doesn't terminate on its own.
  • C. When there are no catch blocks in a try statement.
  • D. When there is exactly one catch block in a try statement.
  • E. When there are two or more catch blocks in a try statement.


C.

Note

A try statement is required to have a catch clause and/or finally clause.

If it goes the catch route, it is allowed to have multiple catch clauses.




PreviousNext

Related