class Person {
//    private
    String name;
//    private
    int age;
    public Person() {
        System.out.println("调用了person的构造方法");
    }    public Person(String name, int age) {
        this.name = name;
        this.age = age;    }    public void show() {
        System.out.println("姓名: " + name + " 年龄: " + age);
    }}
class student extends Person {
    private String department;
    public student() {
        System.out.println("调用了无参构造方法Student()");
    }    public student(String name, int age, String dep) {
     1。   // super(name,age);            //如果省略此句,父类无参数构造方法仍然被调用
      2。  //    this.name=name;           //可传递参数
      3。  //    this.age=age;
     4。 //  new Person(name, age);// **************//为什么不可以传递参数*******************

        this.department = dep;
        System.out.println("我是" + department + "的学生");
        System.out.println("调用了学生里的构造方法Student(String dep)"); 
    }
}
该程序中用红色标记的第一行去掉注释,也就是最标准的程序结果为:调用了person的构造方法
调用了无参构造方法Student()
我是信息的学生
调用了学生里的构造方法Student(String dep)
姓名: null 年龄: 0
姓名: 张三 年龄: 23
第2,3行去掉注释,注释掉第一行
结果: 调用了person的构造方法调用了无参构造方法Student()调用了person的构造方法我是信息的学生调用了学生里的构造方法Student(String dep)姓名: null 年龄: 0姓名: 张三 年龄: 23
注释掉1,2,3把第4行去掉注释,结果调用了person的构造方法调用了无参构造方法Student()调用了person的构造方法我是信息的学生调用了学生里的构造方法Student(String dep)姓名: null 年龄: 0姓名: null 年龄: 0
问:
super()是调用父类的有参构造方法,那么为什么用new 就不可以传递参数呢?如果不用“this.”传递参数也不用super,如何通过调用父类传递参数?为什么调用子类构造方法自动调用父类无参构造方法,而用super则不调用父类无参构造方法,super和new +父类构造方法有何区别?