Knowee
Questions
Features
Study Tools

A superclass' members are accessible anywhere that the program has a reference to an object of that superclass or to an object of one of its subclasses if the members have what access modifier?a.publicb.privatec.protected

Question

A superclass' members are accessible anywhere that the program has a reference to an object of that superclass or to an object of one of its subclasses if the members have what access modifier?a.publicb.privatec.protected

🧐 Not the exact question you are looking for?Go ask a question

Solution

The members of a superclass are accessible anywhere that the program has a reference to an object of that superclass or to an object of one of its subclasses if the members have a 'public' or 'protected' access modifier.

Here's why:

a. Public: The members (fields, methods, etc.) declared as public in a superclass are accessible anywhere in the program.

b. Private: The members declared as private in a superclass are not accessible directly from its subclasses or anywhere outside the class. They are only accessible within the class they are declared.

c. Protected: The members declared as protected in a superclass are accessible within the same package and also in its subclasses irrespective of the package they are declared in.

So, the correct answers are 'public' and 'protected'.

This problem has been solved

Similar Questions

Which access modifier allows member access only within the same class and its subclasses?a.publicb.protectedc.defaultd.private

Which modifier makes a member accessible only within its own class?a.defaultb.protectedc.privated.publicClear my choice

In Java, a subclass can directly access the private members of its superclass.Select one:TrueFalse

Protected members of a superclass are accessible in any class outside the package of the superclass.Select one:TrueFalse

Which access specifier is usually used for data members of a class?a) Protectedb) Privatec) Publicd) Default

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.