🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Adding or reordering constants later changes the numbers, so old data gets the wrong meaning
  2. B.ordinal() is slow
  3. C.ordinal() can be negative
  4. 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 →