問題文
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?
選択肢
- 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.
- 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.
- 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.
- 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.