🎙 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 should you store name() and not ordinal() in a database?

Why should you store name() and not ordinal() in a database?

  1. A.ordinal() is slower
  2. B.Adding or reordering constants later changes the ordinals and breaks old data
  3. C.name() uses less space
  4. 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 →