🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. What does this print? (code)
  2. Q2. What is the accessor method for the component marks in record Student(String name, int marks)?
  3. Q3. What does this print? (code)
  4. Q4. Which is true about records?
  5. Q5. What is a compact constructor in a record used for?
  6. Q6. What does sealed interface Shape permits Circle, Square mean?
  7. Q7. A class listed in permits is declared as plain class Square implements Shape. What happens?
  8. Q8. What does this print? (code)
  9. Q9. What is the main benefit of a switch over a sealed type (Java 21)?
  10. Q10. Which object is a GOOD fit for a record?