フリー問題

Java SE 17 Developer のフリー問題 6 / 20 問目

問題文

A class contains a static initializer block, an instance initializer block, and a constructor body that assigns a field. In which order do the three run while the first instance of that class is being created?

選択肢

  1. The instance block runs ahead of the static block for the first object, since instance state has to exist before class state is set up
  2. The constructor body runs first as the entry point of creation, then the instance block runs, and the static block runs when the object is discarded
  3. The static block runs once while the class is initialized, then the instance block runs, and the constructor body runs after it for every new instance
  4. The static block and the instance block both run once per instance, and the constructor body runs between those two blocks

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

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