Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Protected Java Keyword

protected is a keyword defined in the java programming language

Ads

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>

}
}

Advertisements

Share on Google+Share on Google+

Protected Java Keyword

Posted on: June 9, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Protected Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads