package P1;
abstract public class A {
  void foo () {System.out.println("Afoo");
  }
  void bar () { 
    System.out.println("Abar");
  }
  abstract public void invokeBar();
}
***
package P2;
import P1.A;
public class B extends P1.A {
  public void foo () 
    System.out.println("Bfoo");
  }
  void bar () 
    System.out.println("Bbar");
  }
  public void invokeBar() {
    bar();
  }
}
***
package P1;
public class C extends P2.B {
  public void foo () {
    System.out.println("Cfoo");
  }
  public void bar () {
    System.out.println("Cbar");
  }
  public static void main(String[] args) {
    A ac;
    A ab;
    B bc;
    C c = new C();
    B b = new B();
    ac = c;
    bc = c;
    ab = b;         
    ac.foo();       
    bc.foo();      
    ac.bar();     
    bc.bar();      
    ac.invokeBar(); 
    ab.foo();  
    ab.bar();    
    ab.invokeBar(); 
  }
}