You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

Question image

Understand the Problem

The question is asking which access modifier allows a class to have restricted access to members of another class in the same package. The focus is on identifying the most restrictive access level among the options provided.

Answer

default access

The final answer is default access.

Answer for screen readers

The final answer is default access.

More Information

In Java, the default access level (also known as package-private) ensures that members of a class are accessible only within the same package. This is more restrictive than protected access, which also allows access from subclasses in different packages.

Tips

A common mistake is to confuse 'protected' with 'default' access. Protected allows access from subclasses in different packages, which is less restrictive than 'default' access.

Thank you for voting!
Use Quizgecko on...
Browser
Browser