Protected Java Keyword

protected is a keyword defined in the java programming
language. Keywords are basically reserved words which have specific meaning
relevant to a compiler in java programming language likewise the protected
keyword indicates the following :
-- It is used as an access control modifier.
-- It is applicable to a class, a method or a field.
-- protected method or a variable is only visible to the classes
within the same package.
-- A protected class, method or field are only referenced
from within the class in which it is declared.
Using a protected
Keyword within a classprotected
Keyword within a class
Examples
|
public class ClassName
{
protected class ClassName1;
} |
Declaring Protected Variable
|
public class ClassName
{
protected int i;
}
|
Declaring Protected Method
|
public class ClassName
{
protected int i;
protected String Method()
{
<statements>
<statements>
...
<statements>
}
}
|

|