Difference between public,protected,private,default?
>> Monday, May 30, 2011
public(Modifier): It is used in Outer classes, interfaces,
constructors, Inner classes, methods
and field variables.
Description:A class or interface may be accessed from outside the
package. Constructors, inner classes, methods and field
variables may be accessed wherever their class is
accessed.
protected:Constructors, inner classes, methods,
and field variables.
Description:Accessed by other classes in the same package or any
subclasses of the class in which they are referred (i.e. same
package or different package).
private:Constructors, inner classes,
methods and field variables,
Description:Accessed only within the class in which they are declared
<Default>:Outer classes, inner classes,
interfaces, constructors, methods, and
field variables
Description:Accessed only from within the package in which they are
declared.
constructors, Inner classes, methods
and field variables.
Description:A class or interface may be accessed from outside the
package. Constructors, inner classes, methods and field
variables may be accessed wherever their class is
accessed.
protected:Constructors, inner classes, methods,
and field variables.
Description:Accessed by other classes in the same package or any
subclasses of the class in which they are referred (i.e. same
package or different package).
private:Constructors, inner classes,
methods and field variables,
Description:Accessed only within the class in which they are declared
<Default>:Outer classes, inner classes,
interfaces, constructors, methods, and
field variables
Description:Accessed only from within the package in which they are
declared.
0 comments:
Post a Comment