Java Programming/Keywords/protected
Appearance
From Wikibooks, open books for an open world
protected
is a Java keyword.
This keyword is an access modifier, used before a method or other class member to signify that the method or variable can only be accessed by elements residing in its own class or classes in the same package (as it would be for the default visibility level) but moreover from subclasses of its own class, including subclasses in foreign packages (if the access is made on an expression, whose type is the type of this subclass).
Syntax:
protected
<returnType> <methodName>(<parameters>);
For example:
Computer code
protectedintgetAge(); protectedvoidsetYearOfBirth(intyear);
See also: