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

Is string pool garbage collected?

0 Answers  


Can a top level class be private or protected?

0 Answers  


What is one third plus one third as a fraction?

0 Answers  


Can substring create new object?

0 Answers  


Explain about anonymous inner classes ?

0 Answers  






What is anti pattern in cyber security?

0 Answers  


What is ternary operator?

0 Answers  


What access modifiers can be used for methods?

0 Answers  


What is the difference between interpreter and compiling ?

2 Answers   TCS,


What is java lang object?

0 Answers  


How listener identify that the event came from a particular object?

0 Answers  


What is the use of a conditional inclusion statement in Java ?

0 Answers   Global Logic,


Categories