求java大神,请分析以下代码,写出执行结果,并解释每行结果输出的原因。classPlate{publicPlate(){System.out.println("inPlateconstructor");}}classDinnerPlateextendsPlate{publi...
求java大神,请分析以下代码,写出执行结果,并解释每行结果输出的原因。class Plate {
public Plate() {
System.out.println("in Plate constructor");
}
}
class DinnerPlate extends Plate {
public DinnerPlate() {
System.out.println("in DinnerPlate constructor");
}
}
class Utensil {
Utensil() {
System.out.println("in Utensil constructor");
}
}
class Fork extends Utensil {
public Fork() {
System.out.println("in Fork constructor");
}
}
class Custom {
public Custom() {
System.out.println( "in Custom constructor");
}
}
public class PlaceSetting extends Custom {
Fork fk;
DinnerPlate pl;
public PlaceSetting() {
fk = new Fork();
pl = new DinnerPlate();
System.out.println("in PlaceSetting constructor");
}
public static void main(String[] args) {
PlaceSetting ps = new PlaceSetting();
}
}
展开