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>
...
} |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Protected Java Keyword
Post your Comment