The protected keyword is an access control modifier that may be applied to a class, a method or a field (a variable declared in a class).
If a class or its members are declared as protected are only accessible by the classes of the same package and the subclasses present in any package. You can also say that the protected access modifier is similar to default access modifier with one exception that it has visibility in subclasses.
Classes cannot be declared protected. This access modifier is generally used in a parent-child relationship.
protected Java Keyword Example
Recommended Reading: http://www.javaguides.net/2018/10/java-access-modifiers-public-private-protected-default.html
Comments
Post a Comment
Leave Comment