在Test类中,我B使用 new 关键字创建类的对象 - 在B那里调用类的构造函数:
class A{
public A(){
//initialization of fields
}
}
class B extends A{
public B(){
super();
}
}
class Test(){
public static void main(String... s){
B b=new B();
}
}
这是否意味着每当调用特定类的构造函数时,都会在内存中创建该类的对象?
如果问题的答案是肯定的,那么在上面的例子中,当A使用 调用超类的构造函数时super(),它是否也会创建类的对象A?
这个超类对象会与内存中的子类对象一起创建吗?