← All topics
Quiz: Records and Sealed Classes: 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 accessor method for the component marks in record Student(String name, int marks)?
- Q3. What does this print? (code)
- Q4. Which is true about records?
- Q5. What is a compact constructor in a record used for?
- Q6. What does sealed interface Shape permits Circle, Square mean?
- Q7. A class listed in permits is declared as plain class Square implements Shape. What happens?
- Q8. What does this print? (code)
- Q9. What is the main benefit of a switch over a sealed type (Java 21)?
- Q10. Which object is a GOOD fit for a record?