class A{ public A(){ System.out.println(" String a"); } }class B extends A{public B(){System.out.println("String b");}}class C extends B{public C(){System.out.println("String c");}}public class ConstructorTest{ public static void main(Stringargs[]){C
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 19:45:03
class A{ public A(){ System.out.println(" String a"); } }class B extends A{public B(){System.out.println("String b");}}class C extends B{public C(){System.out.println("String c");}}public class ConstructorTest{ public static void main(Stringargs[]){C
class A{ public A(){ System.out.println(" String a"); } }
class B extends A{
public B(){
System.out.println("String b");
}
}
class C extends B{
public C(){
System.out.println("String c");
}
}
public class ConstructorTest{
public static void main(Stringargs[]){
C c = new C();
}
}
运行结果是什么?
class A{ public A(){ System.out.println(" String a"); } }class B extends A{public B(){System.out.println("String b");}}class C extends B{public C(){System.out.println("String c");}}public class ConstructorTest{ public static void main(Stringargs[]){C
String aString bString c
子类创建实例的时候要调用父类构造方法