package student;
public class Exercise01 {
public static void main(String[] args) {
B b = new B();//a , b name, b
}
}
class A {
A() {
System.out.println("a");
}
A(String name) {
System.out.println("a name");
}
}
class B extends A {
B() {//有this()就不会调用有super()
this("abc");
System.out.println("b");
}
B(String name) {
//默认有 super();
System.out.println("b name");
}
}
package student;
public class Exercise02 {
public static void main(String[] args) {
C c = new C();
}
}
class A {//A类
public A() {
System.out.println("我是A类");
}
}
class B extends A { //B类,继承A类 //main方法中: C c =new C(); 输出么内容? 3min
public B() {
System.out.println("我是B类的无参构造");
}
public B(String name) {//默认调用super()
System.out.println(name + ":我是B类的有参构造");
}
}
class C extends B { //C类,继承 B类
public C() {
this("hello");
System.out.println("我是c类的无参构造");
}
public C(String name) {
super("wty");
System.out.println("我是c类的有参构造");
}
}