class Demo5_Extends {
public static void main(String[] args) {
Son s = new Son("儿子",35);
Son s1 = new Son();
System.out.println(s.name + "..." + s.age);
}
}
class Father extends Object {
String name;
int age;
public Father() {
}
public Father(String name,int age) {
this.name = name;
this.age = age;
}
}
class Son extends Father {
public Son(){
}
public Son(String name,int age){
super(name,age);
}
}
在继承中,父类先于子类进行初始化,那么这个初始化的内容具体是什么?是父类的构造方法还是里面的内容都进行初始化?成员变量是否载入?成员方法是否载入?
|
|