首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

面试题拾掇3

2012-11-07 
面试题整理3以下程序执行后显示什么结果public class Parent {??public Parent(){???System.out.println(

面试题整理3

以下程序执行后显示什么结果

public class Parent {

??public Parent(){
???System.out.println("-----Parent--------");
??}
}

public class Child extends Parent {
?public Child(){
??System.out.println("-------child------");
?}
?Brother b = new Brother();
}

public class Brother {
?public Brother(){
??System.out.println("------brother--------");
?}
}

public class TestChild {

?public static void main(String[] args) {
??System.out.println(new Child());

?}

}

?

------执行结果--------

-----Parent--------
------brother--------
-------child------
test.pro3.Child@6e1408

?

?

-----解释-----

?/**
? * 初始化顺序:
? * 父类变量-》父类构造-》子类变量-》子类构造
? */

热点排行