← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 1 of 10
What does this print? (code)
What does this print?
enum Size { SMALL, MEDIUM, LARGE }
public class Main {
public static void main(String[] args) {
System.out.println(Size.LARGE.ordinal() + " " + Size.values().length);
}
}
- A.3 3
- B.2 3
- C.2 2
- D.LARGE 3
Answer & explanation
Correct answer: 2 3
ordinal starts at 0, so LARGE is 2; there are 3 constants.
Can you get the rest right without peeking?
Take the timed Quiz: Java Enums quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →