![]() |
Java Access Specifiers
One of the prime features of object oriented programming is data encapsulation.This feature enables data to have restricted access.There are currently four different access specifiers in JAVA. Namely,
Public:- All the data members and member functions which are declared public can be accessed from anywhere outside or inside the class which means it can be accessed by any object or through any member functions.It is also called a class level access modifier as class is usually made public in JAVA so that it can be accessed from anywhere. Code:
public class A{ //public classProtected:- Any data member,member functions which are declared as protected can be accessed from within that class and any subclass of that specific class to which they belong whether it is in the same package or different package. The access level remains unchanged while inheritance from one class to the other in JAVA. Default( No specifier):- Any data member,member functions which has no access specifier mentioned to it , it can be accessed from within that package where the class,method or field belongs but not from anywhere outside that package. Sometimes there are no access levels mentioned to a class and this is when the class can be accessed from anywhere within the same package only. Following is the tabular representation for Java access specifiers http://imgs.g4estatic.com/java-acces...specifiers.png |
Re: Java Access Specifiers
Hai Debasmtia !!!!!!!!!!!!!!!!
This is Ajay. Very precisely & shortly you discribed the Java Access Specifiers. Very good. Can you help me ? I have added in yesterday. I am new. I am computer degree student of 4th Sem. I also have some nice articles. But I don't know how to post these articles or here it is said here as a 'Thread'. Please help. I shall be thankfull to you. |
Re: Java Access Specifiers
Java Access specifiers are placed in front of each definition for each member in your class, whether its a field or a method eaech acess specifier controls the access for only that particular definition. Java supports four types types of access specifiers : private, protected, public, and if unspecified, package access.
|
Re: Java Access Specifiers
Very informative post.
The table with access modifiers is very useful. |
| All times are GMT +5.5. The time now is 05:36. |