+ 1
What is the output of this code? Why ?
public class Year { public enum seasons { Spring, summer, autumn, winter } public static void main (String[] args) { int x = 4 % 3; System.out.println (seasons.values( )[ x]); } }
2 Answers
+ 7
You have a compile error with va|ues instead of values. Once fixed, x becomes 1 as 4-3 leaves 1. seasons.values()[1] is summer so that gets printed.
+ 6
Edited your post to add Java tag.



