フリー問題

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

問題文

A class declares a static initializer, an instance initializer, a static field with an initial value, an instance field with an initial value, and a constructor. In what order do these run when the first instance of the class is created?

選択肢

  1. The static field initializer and the static initializer run once in source order, then the instance field initializer and the instance initializer run in source order, and the constructor body runs last.
  2. All initializers run in source order regardless of whether they are static, and the constructor body runs somewhere in the middle of that sequence depending on where it is declared in the file.
  3. The instance initializer runs once for the class in the same way as the static initializer, and the constructor body then runs for every instance.
  4. The constructor body runs first so that its arguments are available, and then the instance field initializer and the instance initializer run in source order.

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

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