フリー問題

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

問題文

A Callable throws a checked exception while it runs inside an executor. What does the caller observe when it invokes get on the Future?

選択肢

  1. An InterruptedException, because the task did not complete normally and the waiting thread is therefore woken up with the interruption signal set on it.
  2. An ExecutionException whose cause is the exception that the task threw, which the caller reads out of it by calling getCause.
  3. The original checked exception, rethrown unchanged, and so a calling method must declare that same type.
  4. A null result, because the exception was already reported on the thread that ran the task and the Future only carries successful outcomes for the caller to read.

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

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