Which keyword can protect a class in a package from accessibility by the classes outside the package?
Answers
Answered by
3
private.
These are the use cases of the different keywords
public : A class may be declared with the modifier public, in which case that class is visible to all classes everywhere.
private : The private modifier specifies that the member can only be accessed in its own class.
protected : The protected modifier specifies that the member can only be accessed within its own package andby a subclass of its class in another package.
These are the use cases of the different keywords
public : A class may be declared with the modifier public, in which case that class is visible to all classes everywhere.
private : The private modifier specifies that the member can only be accessed in its own class.
protected : The protected modifier specifies that the member can only be accessed within its own package andby a subclass of its class in another package.
Similar questions