190k views
1 vote
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

a) Public
b) Protected
c) No Modifier
d) All of the mentioned

User MadRabbit
by
5.4k points

1 Answer

4 votes

Answer:

D) All the mentioned

Step-by-step explanation:

public: This access modifier allows access from all classes in the program

protected: Means only classes within the same package or sub-classes (inheritance) can access members of the class

No Modifier: Omiting the modifier sets a class to the default. Which implies only classes in the same package can access members of the class.

The given question refers to class members in the same package so any these three access modifiers can be used.

User Rahulrvp
by
4.9k points