How does access modifiers work?
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 |
What are checked exceptions?
Does constructor return any value?
Which is the best way of exception handling?
What is the difference between an inner class and a sub-class?
How can we make sure main() is the last thread to finish in java program?
what is thread in Java ?
What are pass by reference and pass by value?
What are the uses of final, finally and finalize in java?
2 Answers Agiline, FINO PayTech, HCL,
What is difference between == equals () and compareto () method?
What is wrapper class html?
Is empty string in java?
How does serialization work