public class HelloWorld
{
  public static void main(String[] args)
  {
    B b = new B();
    b.doStuffB(new A());
  }
  
  public static class A {
    protected void printSomething() {
      System.out.println("a");
    }
  }

  public static class B extends A {
    public void doStuffB(A other) {
      other.printSomething();
    }
  }
}