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




Related Tutorials


 
 

Share on Google+Share on Google+

Scope

Advertisement
A method's visibility is known as method scope.

Scope

     

A method's visibility is known as method scope. We can say that it defines whether a object can invoke as well as any subclass can override the method or not. The scope are generally used as per the need of the program or application, e.g. if a method intended to be access only by the own class of the method then we make the visibility private

There are four type of scope or modifiers of method in java and all the scopes are as under:

Modifier

Can be Accessed By

public The method can be access by any class.
protected The defining method can be access by the same package, class and subclass.
private This type of method can be invoked by the owner class.
No Modifier It also works as same as protected.
Advertisements

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 17, 2009

Related Tutorials

Discuss: Scope  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:3
ST
April 18, 2011
Scope

No Scope Modified is NOT same as protected. It is stricter than protected. Subclass cannot access it, while protected can be accessed.
Christian B
July 13, 2012
not correct

No modifier is NOT the same as protected. It means it's package accessible (as in com.roseindia.*)
onalethata akoonyatse
March 27, 2013
method

i would like to learn everything about Java
DMCA.com