QuestionQ185

Handling Exceptions

Given the following:

Question Image

Which action resolves the compiler error?

  • A At line 17, add throws AccessViolationException
  • B At line 13, add throws LogFileException
  • C At line 2, replace throws LogFileException with throws AccessViolationException
  • D At line 7, insert throw new LogFileException ();
Explanation

LogFileException is a checked exception. Since process() throws it, that method must either catch it or declare it with throws LogFileException. The caller already permits that exception through its own throws LogFileException declaration. AccessViolationException is unchecked because it extends RuntimeException.

Community Discussion

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