QuestionQ116

Handling Exceptions

Review:

Question Image

Which statement is correct?

  • A The program prints m1.Accessed.
  • B The program fails compile due to the unhandled E1 exception.
  • C The program prints m2.Accessed.
  • D The program fails to compile due to the unhandled E2 exception.
Explanation

E1 is a checked exception because it extends Exception. The m1() method throws E1 but neither catches it nor declares it with throws E1, so compilation fails. E2 is unchecked because it extends RuntimeException.

Community Discussion

No comments yet. Be the first to start the discussion!