Exemple #1
0
  public static void main(String args[]) {
    A superOb = new A();
    B subOb = new B();

    // The superclass may be used by itself.
    superOb.i = 10;
    superOb.j = 20;

    System.out.println("Contents of superOb:");
    superOb.showij();
    System.out.println();

    /*The subclass has access to all public members of
    its superclass*/
    subOb.i = 7;
    subOb.j = 8;
    subOb.k = 9;
    System.out.println("Contents of subOb: ");
    subOb.showij();
    subOb.showk();
    System.out.println();
    System.out.println("Sum of i,j and k in subOb:");
    subOb.sum();
  }
  void f() {

    A a0 = new A();
    a0.i = 0;
  }
Exemple #3
0
 public void m(A a1, A a2) {
   a1.i = 41;
   a2.i = 42;
 }