1.首先是interface (接口可以多继承)
the interface can inherit any number of other interface .
you can have a try to verify the code above
2.接着是 inheritance
what is the output ?
it is :
A
B
Why ?
每个子类构造方法的第一条语句都是隐含的调用super,如果父类没有这种形式的构造函数就会报错.
if the class which is inherited have a constructor with arguments, what will happen ?
interface i1 {}
interface i2{}
interface i3 extends i1,i2 {}
the interface can inherit any number of other interface .
you can have a try to verify the code above
2.接着是 inheritance
class A{
public A (){
System.out.println("A");
}
class B{
public B (){
System.out.println("B");
}
public static void main(String arg[]){
B b = new B();
}
}
what is the output ?
it is :
A
B
Why ?
每个子类构造方法的第一条语句都是隐含的调用super,如果父类没有这种形式的构造函数就会报错.
if the class which is inherited have a constructor with arguments, what will happen ?