← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 6 of 10
Why should you store name() and not ordinal() in a database?
Why should you store name() and not ordinal() in a database?
- A.ordinal() is slower
- B.Adding or reordering constants later changes the ordinals and breaks old data
- C.name() uses less space
- D.ordinal() can be negative
Answer & explanation
Correct answer: Adding or reordering constants later changes the ordinals and breaks old data
Ordinals depend on the declared order, which can change as the code grows.
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 →