← Quiz: Java Enums: all 10 questions
Quiz: Java Enums · Question 6 of 10
Why is storing ordinal() in a database a bad idea?
Why is storing ordinal() in a database a bad idea?
- A.Adding or reordering constants later changes the numbers, so old data gets the wrong meaning
- B.ordinal() is slow
- C.ordinal() can be negative
- D.Databases cannot store numbers
Answer & explanation
Correct answer: Adding or reordering constants later changes the numbers, so old data gets the wrong meaning
name() stays stable when new constants are inserted; ordinal() does not.
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 →