フリー問題

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

問題文

An enum declares one field, a constructor that takes a single argument, and a getter for the field. Which statement about that enum is accurate?

選択肢

  1. Each constant passes its own argument to the constructor at the point where the constant is declared, and the constructor is implicitly private
  2. The constructor runs each time one of the constants is read, so the getter observes a freshly built value
  3. The field has to be declared static, because every one of the constants of an enum type shares a single copy of the state
  4. The constructor has to be declared public so that the constants are able to reach it, because those constants live outside the body of the enum type

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

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