Skip to content
Sharp

Object-oriented programming · interview question

Which keyword in Java is used to restrict access to members of a class?

Multiple choiceEasychapter-3-curatedpremiumoopcontrolled-mutation
Choose one answer
Answer and explanation

Correct answer

A. Private

Why

The 'private' keyword is used to restrict access to class members, allowing access only within the class itself, thereby supporting encapsulation.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →