We covered nearly 50 + primary Java interview questions in this tutorial for fresh and experienced candidates. Q.1- What is Java? Java is a high-level programming language and is platform-independent.…
Explain about Public and Private access specifiers in Java
Methods and instance variables are known as members.
Public members are visible in the same package as well as the outside package that is for other packages.
Public members in Class A are visible to Class B (Same package) as well as Class C (Different package).
Private members are visible in the same class only and not for the other classes in the same package as well as classes in the outside packages.
Private members in class A is visible only in that class. It is invisible for class B as well as class C.