← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 2 of 10
What is the main advantage of an enum over int constants for a method parameter?
What is the main advantage of an enum over int constants for a method parameter?
- A.The compiler only accepts valid constants of that type
- B.Enums use less memory than ints
- C.Enums can be added together
- D.Enums are faster to print
Answer & explanation
Correct answer: The compiler only accepts valid constants of that type
A Status parameter cannot receive 42 or any other invalid value; an int parameter can.
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 →