// DDD.java -- double dynamic dispatch

class Base {
   void method1 () {
      System.out.println ("Base.method1()");
      method2();   // Method to invoke is chosen dynamically
   }
   void method2 () { System.out.println ("Base.method2()"); }
}

class Derived extends Base {
   void method1 () {
      System.out.println ("Derived.method1()");
      super.method1();
   }
   void method2 () { System.out.println ("Dervied.method2()"); }
}

public class DDD {
   public static void main (String[] args) {
      new Derived().method1();
      new Base().method1();
   }
}