Public modifiers
In Java, there are two access modifiers that we can use for classes: “public” and “default” (also known as package-private).
Public: When we declare a class with the “public” modifier, it becomes visible in various scenarios:
-
- It is visible within the same class where it is defined.
- It is also visible in any subclass that belongs to the same package as the class.
- Additionally, it is visible in any non-subclass (a regular class) within the same package.
- Furthermore, it remains visible in any subclass even if it belongs to a different package.
- Lastly, it is visible in any non-subclass, even if it belongs to a different package.
Remember, the “public” access modifier allows a class to be accessed from anywhere, making it more widely accessible. On the other hand, the “default” access modifier restricts access to within the same package only.

Related Posts
Analog and Memory Layout Design Forum |
Physical Layout Design Forum |
RTL & Verilog Design Forum |
Semiconductor Forum |
Analog Layout Design Interview Questions | Memory Design Interview Questions |
Physical Design Interview Questions | Verilog Interview Questions |
Digital Design Interview Questions | STA Interview Questions |