← All topics
Quiz: Java Enums: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What is the main advantage of an enum over int constants?
- Q2. What does this print? (code)
- Q3. Which statement about an enum's constructor is true?
- Q4. What happens with Day.valueOf("sun") when the constant is declared as SUN?
- Q5. What does this print? (code)
- Q6. Why is storing ordinal() in a database a bad idea?
- Q7. Can an enum extend another class?
- Q8. What does this print? (code)
- Q9. Why is == safe for comparing enum values?
- Q10. Which collection is designed for enum keys and keeps them in declaration order?