The Java Program: another/Unrelated.java

  1 package another;
  2 
  3 import one.Main;
  4 
  5 class AlsoSub extends Main {
  6    private int i = x;  // can access public methods of "Main"
  7    private int j = z;  // can access protected variables of "Main"
  8 
  9 }
 10 
 11 public class Unrelated {
 12    private Main m = new Main();
 13    private int h = m.x;  // can only access public methods of "Main"
 14 }