以下程序执行后显示什么结果
public class parent {
public parent(){<br> system.out.println("-----parent--------");<br> }<br>}
public class child extends parent {<br> public child(){<br> system.out.println("-------child------");<br> }<br> brother b = new brother();<br>}
public class brother {<br> public brother(){<br> system.out.println("------brother--------");<br> }<br>}
public class testchild {
public static void main(string[] args) {<br> system.out.println(new child());
}
}
------执行结果--------
-----parent--------<br>------brother--------<br>-------child------<br>[url=mailto:test.pro3.child@6e1408]test.pro3.child@6e1408[/url]
-----解释-----
/**<br> * 初始化顺序:<br> * 父类变量-》父类构造-》子类变量-》子类构造 <br> */
public class parent {
public parent(){<br> system.out.println("-----parent--------");<br> }<br>}
public class child extends parent {<br> public child(){<br> system.out.println("-------child------");<br> }<br> brother b = new brother();<br>}
public class brother {<br> public brother(){<br> system.out.println("------brother--------");<br> }<br>}
public class testchild {
public static void main(string[] args) {<br> system.out.println(new child());
}
}
------执行结果--------
-----parent--------<br>------brother--------<br>-------child------<br>[url=mailto:test.pro3.child@6e1408]test.pro3.child@6e1408[/url]
-----解释-----
/**<br> * 初始化顺序:<br> * 父类变量-》父类构造-》子类变量-》子类构造 <br> */