class Exam9 {
public static void main(String[] args) {
people p=new graduate();}
}
class people{
String name;
int age;
people(){}
people(String name,int age){
this.name=name;
this.age=age;
System.out.println("In people"); }
}
class student extends people{
String school;
student(){
this(null,0,null);
System.out.println("In student1"); }
student(String name,int age,String school){
super(name,age);
this.school=school;
System.out.println("In student2"); }
}
class graduate extends student{
graduate(){
System.out.println("In graduate"); }
}
输出结果
In people
In student2
In student1
In graduate
想问一下为什么会先从In people开始依次输出,而不是直接输出 In graduate呢?
谢谢!