Java OCA OCP Practice Question 611

Question

Fill in the blanks:

A program must handle or declare ___ but should never handle ___.

  • A. java.lang.Error, unchecked exceptions
  • B. checked exceptions, java.lang.Error
  • C. java.lang.Throwable, java.lang.Error
  • D. unchecked exceptions, java.lang.Exception


B.

Note

Checked exceptions must be handled or declared or the program will not compile, while unchecked exceptions can be optionally handled.

java.lang.Error should never be handled by the application because it often indicates an unrecoverable state in the JVM, such as running out of memory.

Option B is the correct answer.




PreviousNext

Related