Access modifiers
There are three explicit access modifiers—public, private, and protected—and one implicit (default) access modifier that is implied when no access modifier is set. They can be applied to the top-level class or interface, their members, and constructors. A top-level class or interface can include a member class or interface. Other members of a class or interface are fields and methods. Classes also have constructors.
To demonstrate the accessibility, let's create a com.packt.javapath.Ch07demo.pack01
package that contains two classes and two interfaces:
public class PublicClass01 { public static void main(String[] args){ //We will write code here } } class DefaultAccessClass01 { } public interface PublicInterface01 { String name = "PublicInterface01"; } interface DefaultAccessInterface01 { String name = "DefaultAccessInterface01"; }
We will also create another com.packt.javapath.Ch07demo.pack02
package with one class in it:
public class PublicClass02 { public static...