Question:
Access specifiers: "public", "protected", "private", nothing?
Answer:
Public : Any other class from any package can instantiate and execute the classes and methods. Protected : Only subclasses and classes inside of the package can access the classes and methods. Private : The original class is the only class allowed to execute the methods. Source: CoolInterview.com
the three acess specifiers public, private, protected. public means can run outside the class, private means can run within the class.protected means it takes the similarities of both the public and private and it runs according to those specifiers Source: CoolInterview.com
Answered by: sajida shaik | Date: 1/22/2010
| Contact sajida shaik
public:the class members of any package can access the base class. private:only the members of base class can access to it. protected:it is used in case of inheritence,only the immediate sub-class members can access the base class. Source: CoolInterview.com
Answered by: Gaurav Srivastava | Date: 2/15/2010
| Contact Gaurav Srivastava
there are 4 access specifier in java public,private,protected,friendly. Source: CoolInterview.com
Answered by: tejendra pratap singh | Date: 3/19/2010
| Contact tejendra pratap singh
Dear Friend,
With regard to access specifier, friend is the defualt specifier when we donot specify any specifier, otherwise mostly we write public meaning methods of outside class can access it. Example(analogy): members outside your members can access your items. Protected is like jwelery of your family can be access by your parents, followed by grand children but not outside the classes, whereas private access limit the accessibilty of members. Thanks Manish Source: CoolInterview.com
Answered by: Manish Kumar Gupta | Date: 6/8/2010
| Contact Manish Kumar Gupta
private modifiers can be accessed from only withing the same class. default modifiers allow access within the same package alone. protected modifiers allow access in the same package as well as access to its subs classes. public modifiers allow all access i.e. from other packages as well. Source: CoolInterview.com
Answered by: sharat singh | Date: 6/16/2010
| Contact sharat singh
There are 3 main access specifiers.. 1.Public() :-anything declared as public can access from anywhere. 2.Private() :-Anything declared as private can not be seen outside of its class. 3.Protected() :-Anything declared as protected can be accessed by classes in the same package & subclasses in the other package.. if we wont declare any access specifier it will take default. Source: CoolInterview.com
Answered by: YUVARAJ.M | Date: 7/19/2010
| Contact YUVARAJ.M
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|