Skip to content
Sharp

Modern Java · interview question

In Java, which method is NOT automatically generated for a record?

Multiple choiceEasychapter-7-curatedpremiummodern-javarecords
Choose one answer
Answer and explanation

Correct answer

B. Setters

Why

Java records automatically generate methods like equals(), hashCode(), and toString(), but they do not generate setters because records are immutable data carriers with final fields.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →