Skip to content
Sharp

Object-oriented programming · interview question

Which access modifier allows a class member to be accessed within the same package but not from outside the package?

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

Correct answer

B. Package-private

Why

The package-private access level, also known as default access, allows access to class members only within the same package. No explicit keyword is used for this level.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →