Type Here to Get Search Results !

What is a "protected" member in a class?

0

 What is a "protected" member in a class?

A) It can only be accessed within the same class.
B) It can be accessed within the same package and by subclasses.
C) It can be accessed from any class.
D) It can only be accessed from subclasses in the same package.

Answer: B) It can be accessed within the same package and by subclasses.

Explanation: A "protected" member in a class can be accessed by classes in the same package and by subclasses, even if those subclasses are in different packages. This access modifier allows for greater flexibility compared to private members while still providing some encapsulation.

Post a Comment

0 Comments