What are the various access modifiers in Java. Differences between them

Showing Answers 1 - 3 of 3 Answers

Pattukkottai Arun

  • Jul 21st, 2005
 

There are four levels of access specifiers in Java. They are Public, Private and Protected. an default. 
PUBLIC: If the method or the variable is declared public, then it will be visible to all classes of the program.  
PRIVATE: If the method or the variable is declared private , then it will be visible only to the class it is defined.  
PROTECTED: This is same as Public but it will give more protection than the public. If Protected is used then all the methods and attributes of the base class will be available to all its derived classes.

Rajesh Sakhamuri

  • Nov 2nd, 2005
 

By Rajesh:Access modifiers are bstract,static,final,interface.static members are created only one copy,that copy can be shared with all the objects.static class can access only static members.final:if u declear the final variable with some value, that value throughout the pgm is constant.final class canot inherited.

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 11th, 2006
 

abstract,static,final and interface cannot be considered as access modifiers. The access modifiers in Java are public, private and protected.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions