interface Type1 {
    void f() throws CloneNotSupportedException;
}interface Type2 {
    void f() throws InterruptedException;
}interface Type3 extends Type1, Type2 {
}public class Arcane3 implements Type3 {
    public void f() {
        System.out.println("Hello world");
    }
    public static void main(String[] args) {
        Type3 t3 = new Arcane3();
        t3.f();
    }
}这个程序编译过了。。也能执行出结果。。
有点颠覆我以前的理解了 Type3怎么能继承两个  望解释详细点
还有。。这个里面异常的问题也望能解释解释

解决方案 »

  1.   

    1.接口可以多继承
    3.Each interface limits the set of checked exceptions that method f can throw. The set of checked exceptions that a method can throw is the intersection of the sets of checked exceptions that it is declared to throw in all applicable types, not the union. As a result, the f method on an object whose static type is Type3 can't throw any checked exceptions at all. Therefore, Arcane3 compiles without error and prints Hello world.
    也就是可以抛出的是异常的交集,而不是并集。
    参考:java puzzlers-----Puzzle 37: Exceptionally Arcane
      

  2.   

    接口可以继承多个,但是Type1和Type2的方法名都相同,应该有问题的吧?
      

  3.   

    其实不需要用Type3,直接写成public class Arcane3 implements Type1,Type2{}
    也一样的。
    "interface Type3 extends Type1, Type2 { } "
    这里有点问题:能继承两个接口吗?
      

  4.   

    java中的接口是可以多继承的。类不可以。
      

  5.   

    java里的类只能够单继承类, 多实现接口接口可以继承多个  这在java里的说法叫接口的扩展 没有任何问题