class CData{
CData(){System.out.println("data is set");}
}
class LoadP{
static CData cd1 = new CData();
private CData cd2 = new CData();
LoadP(){System.out.println("parent construct");}
}
class LoadC extends LoadP{
LoadC(){System.out.println("child construct");}
}
class LoadC2 extends LoadP{
LoadC2(){System.out.println("another child construct");}
}
class LoadTest{
LoadTest(){System.out.println("init");}
public static void main(String[] args){
LoadC lc = new LoadC();
LoadC2 lc2 = new LoadC2();
}
}
1、执行LoadC lc=new LoadC()时;先装入LoadP.class,再装入LoadC.class,不知正确否(将CData视为数据,暂不讨论)?
2、执行实例化时,根据.class 给实例变量分配内存,而不给方法和类变量分配?
|