Skip to content
Sharp

Object-oriented programming · interview question

Which access modifier should be used for a method that is only intended to be used within its own class?

Multiple choiceEasychapter-3-curatedpremiumoopaccess-modifiers-and-visibility
Choose one answer
Answer and explanation

Correct answer

B. Private

Why

The 'private' access modifier should be used for methods intended only for use within their own class. This restricts access to the method, supporting encapsulation by hiding implementation details.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →