Access Modifiers in JAVA
Access Modifiers are used to Control the access and to maintain the confidentiality of the classes and it's members. There are two access levels in JAVA where access modifiers are applicable. namely, class level member level In Java we have four access modifiers. namely, Public Protected Default Private Class Level Only Public and Default access modifiers are applicable for class level declaration. public This can be access from anywhere either from the inside of the package or the outside of the package . If a public class needed to be accessed from the outside of the package, it is a must to import that package which contains that class. package test; import access_modifiers . PublicClass ; TestPublic{ PublicClass pc = new PublicClass(); } package access_modifiers ; public class PublicClass { } We are not using the import statement when accessing a class inside the same package. default There is no keyword for the default acces