フリー問題

Java SE 21 Developer Professional のフリー問題 11 / 20 問目

問題文

A custom exception should report the low level failure that led to it. What is the recommended way to carry that information?

選択肢

  1. Provide a constructor that takes a message and a Throwable cause, and pass the original exception as that cause when wrapping it.
  2. Extend the original exception class so that catching the custom type also catches the original one.
  3. Put the text of the original exception into the message, while the original object itself is not retained.
  4. Store the original exception in a static field of the custom exception class so that any handler anywhere in the application can reach it without extra plumbing.

解答・解説を確認するには

正解と解説の確認、回答の記録には無料登録が必要です。登録すると演習モードでフリー問題に回答し、正誤と解説をその場で確認できます。