Java OCA OCP Practice Question 1357

Question

Which of the following exception types must be handled or declared by the method in which they are thrown?

  • A. NullPointerException
  • B. Exception
  • C. RuntimeException
  • D. ArithmeticException


B.

Note

NullPointerException and ArithmeticException both extend RuntimeException, which are unchecked exceptions and not required to be handled or declared in the method in which they are thrown.

On the other hand, Exception is a checked exception and must be handled or declared by the method in which it is thrown. Therefore,

Option B is the correct answer.




PreviousNext

Related