← 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 does this print? (code)
- Q2. What is the main advantage of an enum over int constants for a method parameter?
- Q3. What does Status.valueOf("shipped") do if the constant is named SHIPPED?
- Q4. What does this print? (code)
- Q5. Which statement about an enum constructor is true?
- Q6. Why should you store name() and not ordinal() in a database?
- Q7. Can an enum extend another class?
- Q8. What does this print? (code)
- Q9. How do you compare two enum values a and b for equality?
- Q10. Which is a simple, thread-safe way to write a Singleton in Java?