Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Help Java P Protected Java Keyword

Related Tutorials


 
 

Share on Google+Share on Google+

Protected Java Keyword

Advertisement
protected is a keyword defined in the java programming language

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>

}
}

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 9, 2009

Related Tutorials

Discuss: Protected Java Keyword  

Post your Comment


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