Given:.
1. public class Main { 2. static MyClass w; 3. public static void main(String[] args) { 4. System.out.print(w.Summer.count + " " + w.Sunny.count + " "); 5. } /*from ww w. j av a 2 s . c om*/ 6. } 7. enum MyClass { 8. Summer, Sunny; 9. int count = 0; 10. MyClass() { 11. System.out.print("c "); 12. count++; 13. } 14. }
What is the result?.
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.