MCQ Single Best Answer Easy

QThe use of protected keyword to a member in a class will restrict its visibility as follows:

ID: #24251 Elements of Accounting 41 views
Question Info
#24251Q ID
EasyDifficulty
Elements of AccountingTopic

Choose the Best Option

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

  • A visible only in the class and its subclass in the same package
  • B visible only inside the same package
  • C visible in all classes in the same package and subclasses in other packages
  • D visible only in the class where it is declared
Correct Answer: Option C

Explanation

The use of protected keyword to a member in a class will restrict its visibility as follows:

  • protected → Accessible in:

    • same package (all classes inside it) ✅

    • subclasses even in other packages

So the correct answer is:
(c) visible in all classes in the same package and subclasses in other packages

Share This Question

Challenge a friend or share with your study group.