Skip to content
Sharp

Modern Java · interview question

How can you define a custom method within a Java record?

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

Correct answer

A. By adding instance methods like any other class.

Why

You can define custom instance methods within a Java record just like in any other class, allowing you to add behavior beyond the default generated methods.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →