MethodFailure4.java 603 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
import java.util.*;

public class MethodFailure4 {

  public static String call(A obj) {
    return "A";
  }
  public static String call(I obj) {
    return "I";
  }

  interface I {}
  static class A {}
  static class B extends A implements I {}
  static class C extends B {}


  public static A getA() {
    return new A();
  }

  public static B getB() {
    return new B();
  }

  public static C getC() {
    return new C();
  }

  public static I getI() {
    return new C();
  }
  
  // this method invocation is ambiguous
  
  public static void main(String[] argv) {
    call( getC() );
  }

}