继承条件下构造方法的执行过程

 

 

package com.msb10;

/**
 * @Auther:liu
 * @Date:-09:58:29
 * @Description:IntelliJ IDEA
 * @Version:1.0
 */
public class Person {
    int age;
    String name;

    public Person() {
    }

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
package com.msb10;

/**
 * @Auther:liu
 * @Date:-09:59:18
 * @Description:IntelliJ IDEA
 * @Version:1.0
 */
public class Student extends Person{
    double height;
    //空构造器
    public Student() {
    }
    //有参构造器
    public Student(int age, String name, double height) {
        super(age, name);
        this.height = height;
    }
}
package com.msb10;

/**
 * @Auther:liu
 * @Date:-10:02:10
 * @Description:IntelliJ IDEA
 * @Version:1.0
 */
public class Test {
    //这是一个main方法:是程序的入口
    public static void main(String[] args) {
        Student s=new Student(18,"feifei",16.08);
    }
}

 

posted @ 2022-09-09 10:09  爱的加勒比  阅读(35)  评论(0)    收藏  举报