Multiple choice java

For a subclass outside the package, the protected member can be accessed through ?

  1. Object of super class

  2. Inheritance

  3. Both

  4. None

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Protected members in Java are accessible within the same package and through inheritance to subclasses. For a subclass outside the package, the protected member can only be accessed through inheritance (not via a superclass object reference).