Skip to content
Sharp

Modern Java · interview question

Which of the following is NOT true about the canonical constructor in Java Records?

Multiple choiceHardchapter-12-curatedpremiummodern-javajava-records
Choose one answer
Answer and explanation

Correct answer

C. It can include additional fields not defined in the record components

Why

In Java Records, the canonical constructor can only include the fields defined in the record components. You cannot add additional fields that are not part of the record definition.

Test yourself on Modern Java

A free test with instant, explained results. No account needed.

Start free test
All Modern Java questions →