How does access modifiers work?



How does access modifiers work?..

Answer / javamasque

Public: It is the highest visibility access modifier. It makes visible the class members (variables/methods) to any classes (child/non-child) present within same or any package.
Protected: It has lesser visibility than public access modifier. It makes visible the class members (variables/methods) to sub-classes within same or different package and it also make visible in any class of same package.
Default: It has lesser visibility than protected access modifier. It makes visible the class members (variables/methods) to any classes within same package only.
Private: It has least visibility than all access modifiers. It makes visible the class members (variables/methods) within same class only.

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are different type of access modifiers?

3 Answers  


How to display all the prime numbers between 1 and 100

0 Answers  


What is the purpose of the system class in java?

0 Answers  


suppose we have an interface & that interface contains five methods. if a class implements that interface then we have to bound that to give tha definition of all five methods in that class. If we declare that class as abstract then can we call only two methods to give the deinition of that method & i don't want to give the definition of all the methods? can it possible

6 Answers   HP, Wipro,


Can we restart a thread already started in java?

0 Answers  


Which variables are stored in stack?

0 Answers  


What is the difference between Integer and int?

10 Answers   Infosys,


What is difference between add() and addelement() in vector?

0 Answers  


Explain public static void main(string args[]).

0 Answers  


Program to Find the second largest element in an array.

0 Answers   Amazon,


What is integer valueof?

0 Answers  


What is classname class in java?

0 Answers  


Categories