Skip to content
Sharp

Modern Java · interview question

How can you add behavior to a Java record?

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

Correct answer

D. By defining instance methods within the record body.

Why

To add behavior to a Java record, you can define instance methods within the record body. This allows you to include logic and operations that can be performed on the record's data, while maintaining its immutable characteristics.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →