Skip to content
Sharp

Modern Java · interview question

Which visibility of a field in a Java record is the default in Java?

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

Correct answer

D. Private

Why

In Java records, fields are private by default to ensure encapsulation. Accessor methods are automatically generated to access these fields.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →