← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 1 of 10
What is the main advantage of an enum over int constants?
What is the main advantage of an enum over int constants?
- A.Enums use less memory than ints
- B.The compiler only allows the declared constants, so invalid values are caught
- C.Enums can be used in arithmetic
- D.Enums are faster to compare
Answer & explanation
Correct answer: The compiler only allows the declared constants, so invalid values are caught
A parameter of type Drink cannot receive 42, unlike an int parameter.
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 →