今天面试题目,两接口有一相同签名的方法,又一接口继承了这两接口,如下,
又一类实现了这一接口,
当时我认为这样会错,会让编译器不知道实现的是那个接口中的方法.
回来运行了下,完全可以正常运行.
不知道如何解释?
public interface AI {
public void play();
}
public interface BI {
public void play();
}
public interface ABI extends AI,BI{
Test t = new Test("hello,world");
}
public class Test implements ABI{
private String name;
public Test(String name){
this.name = name;
}
public static void main(String[] args){
t.play();
}
public void play() {
System.out.println(name);
}
}
接口中的属性默认是final和static的