/*
* -->在Person类的构造函数中设定一个输出语句,
-->当创建号GoodStudent对象后,看是否输出语句被执行
-->通过以下实验,该方法可行
* 如下程序运行结果为
* Person is running
Stu is running
goodstu is running
说明在创建GoodStudent时是否调用了Person的构造函数
在GoodStudent中无法指定调用Person的构造函数,
都是默认第一个函数构造函数
* */
class Person{
Person(){
System.out.println("Person is running");
}
Person(int number){
System.out.println("the numbei is::"+number);
}
}
class Students extends Person{
Students(){
System.out.println("Stu is running");
}
}
class GoodStudent extends Students{
GoodStudent(){
System.out.println("goodstu is running");
}
GoodStudent(int num){
System.out.println("goodstu is running"+num);
}
}
public class Test9 {
public static void main(String[] args) {
GoodStudent goodstu = new GoodStudent();
GoodStudent goodstu1 = new GoodStudent(1);
// goodstu.setIfo("zhangsan", 30);