Skip to content
Sharp

Object-oriented programming · interview question

In Java, what access level allows a field to be accessed only within its own class?

Multiple choiceEasychapter-3-curatedpremiumoopencapsulation
Choose one answer
Answer and explanation

Correct answer

A. Private

Why

The 'private' access level allows a field to be accessed only within its own class. This is the most restrictive access level and is used to encapsulate data, protecting it from unauthorized external access.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →