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 some examples of variable costs?

0 Answers  


How does serialization work

3 Answers   Ordain Solutions,


What are the types of inner classes (non-static nested class) used in java?

0 Answers  


Hi Friends, can you give difference between extending thread class and implementing runnable interface.

4 Answers  


What is jvm? Why is java called the platform independent programming language?

0 Answers  






What is string pool in java?

0 Answers  


How to sort double array in java?

0 Answers  


Can we overload run() method in java?

0 Answers  


Can you give few examples of final classes defined in java api?

0 Answers  


What about method local inner classes or local inner classes in java?

0 Answers  


can we write a program with out a class in core java?

11 Answers   Wipro,


What is meant by final class?

0 Answers  


Categories