The Java Program: one/Main.java

  1 package one;
  2 
  3 import another.Unrelated;
  4 
  5 // Can't import "another.AlsoSub"; it is not public
  6 // Can't import "one.Unrelated"; same name as in "another"
  7 
  8 public class Main  {
  9 
 10    int a,b,c;
 11 
 12    public    int x;
 13    private   int y;
 14    protected int z;
 15 
 16    Unrelated u;
 17    one.Unrelated uu;    // can access "one.Unrelated"
 18 
 19    public static void main (String args[])  {
 20    }
 21 }
 22 
 23 class Sub extends Main {
 24    private int d = a;    // can access "package" variables
 25    private int e = z;    // can access protected variables of "Main"
 26 }
 27 
 28 class AlsoUnrelated  {
 29    private Main m = new Main();
 30    private int f = m.a;  // can access "package" variables
 31    private int g = m.z;  // can access protected variables of "Main"
 32 }