MCQ Single Best Answer Easy

QWe would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this ?

ID: #24250 Elements of Accounting 56 views
Question Info
#24250Q ID
EasyDifficulty
Elements of AccountingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A private
  • B protected
  • C public
  • D private protected
Correct Answer: Option B

Explanation

Access modifiers in Java (for class members)

  • private → visible only inside the same class.

  • default (no keyword) → visible inside the same package only.

  • protected → visible inside the same package + visible in all subclasses (even if in a different package).

  • public → visible everywhere.

  • private protected → ❌ Not a valid keyword in Java.


Your question:

We want a member of a class visible in all subclasses, regardless of the package.

✅ That’s exactly what protected does.


Correct Answer:

(b) protected

Share This Question

Challenge a friend or share with your study group.