Skip to content
Sharp

Modern Java · interview question

Why do accessor methods in Java Records not use the 'get' prefix?

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

Correct answer

A. They are automatically generated to match the field names

Why

In Java Records, accessor methods are generated without the 'get' prefix to match the field names directly, simplifying the API and making it more intuitive.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →