QuestionQ65

Exception Handling

Given:

Question Image

and this code fragment:

Question Image

What is the outcome?

  • A Caught java.lang.Exception
  • B Caught p1.ZeroValueException
  • C Caught java.lang.NullPointerException
  • D Caught null
Explanation

The inner handler catches the ZeroValueException and rethrows that same exception. The outer catch (Exception e) receives it, and concatenating an exception with a string uses its toString() representation. Since the exception has no message, the output is Caught p1.ZeroValueException.

Community Discussion

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