What is the output of the following application?
package weather; public class Main { public enum Size { S, M, L } public static void main(String[] modelData) { System.out.print(Size.S.ordinal()); System.out.print(" "+Size.valueOf("flurry".toUpperCase()).name()); } }
A.
The code compiles without issue, so Option C is incorrect.
Enum ordinal values are indexed starting with zero, so 0 is printed first.
The second line compiles and runs without issue, with flurry being converted to L, using the toUpperCase()
method.
Since there is a matching enum named L, that value is printed next.
For these reasons, Option A is the correct answer.