What is the result?
A. c 1 c 1
B. c 1 c 2
C. c c 1 1
D. c c 1 2
E. c c 2 2
F. Compilation fails.
G. An exception is thrown at runtime.
Answer (for Objective 1.1):
C is correct. All of an enum’s values are initialized at the same time, and an enum’s
variables are treated as if they were instance variables, not static variables.
A, B, D, E, F, and G are incorrect, based on the above.
thank you for your reply.Exactly according to your answer the enum constant initialization happens before main() is executed,i.e when the class is loaded at runtime. So printing the count values of the 2 enum constants in main() should print 2 2, not 1 2 as the correct answer says, right?