← Quiz: Records and Sealed Classes: all 10 questions
Quiz: Records and Sealed Classes · Question 5 of 10
What is a compact constructor in a record used for?
What is a compact constructor in a record used for?
- A.Making the record smaller in memory
- B.Removing the generated toString
- C.Validating or adjusting the parameters before the fields are assigned
- D.Adding new instance fields
Answer & explanation
Correct answer: Validating or adjusting the parameters before the fields are assigned
Its code runs first; then the (possibly adjusted) parameters are assigned to the fields automatically.
Can you get the rest right without peeking?
Take the timed Quiz: Records and Sealed Classes quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →