love fish大鵬一曰同風(fēng)起,扶搖直上九萬里

          常用鏈接

          統(tǒng)計

          積分與排名

          friends

          link

          最新評論

          類初始化與對象初始化 (轉(zhuǎn))

          what's the output?
          /**
          ?* @author 031202
          ?*
          ?* TODO To change the template for this generated type comment go to
          ?* Window - Preferences - Java - Code Style - Code Templates
          ?*/
          class Parent {
          ?
          ?class InnerClass {
          ??public InnerClass() {
          ???System.out.println("Construct parent's inner class");
          ??}
          ?}
          ?
          ?static class StaticInner {
          ??public StaticInner() {
          ???System.out.println("Construct parent's StaticInner class");
          ??}
          ?}
          ?
          ?private InnerClass i = new InnerClass();
          ?
          ?private static StaticInner s = new StaticInner();
          ?
          ?public Parent() {
          ??System.out.println("Construct Parent");
          ?}

          }

          public class Child extends Parent {
          ?class InnerClass {
          ??public InnerClass() {
          ???System.out.println("Construct child's inner class");
          ??}
          ?}
          ?
          ?static class StaticInner {
          ??public StaticInner() {
          ???System.out.println("Construct child's StaticInner class");
          ??}
          ?}
          ?
          ?private static StaticInner s = new StaticInner();
          ?
          ?private InnerClass i = new InnerClass();
          ?
          ?public Child() {
          ??System.out.println("Construct Child");
          ?}
          ?
          ?public static void main(String[] args) {
          ??new Child();
          ?}
          }
          answer:
          Construct parent's StaticInner class
          Construct child's StaticInner class
          Construct parent's inner class
          Construct Parent
          Construct child's inner class
          Construct Child

          Do you really understnand? the class initialization?


          posted on 2007-03-16 17:07 liaojiyong 閱讀(322) 評論(0)  編輯  收藏 所屬分類: Java

          主站蜘蛛池模板: 阿克陶县| 白水县| 郑州市| 盐山县| 房山区| 阳谷县| 滨海县| 石阡县| 双桥区| 赤水市| 进贤县| 修文县| 巴楚县| 左贡县| 应城市| 独山县| 桐庐县| 许昌市| 吉安县| 牡丹江市| 四平市| 洞口县| 丰县| 慈利县| 淮南市| 新和县| 合山市| 洪湖市| 竹溪县| 三原县| 囊谦县| 隆回县| 沁水县| 广河县| 龙南县| 息烽县| 乐亭县| 柘城县| 上思县| 西乌| 平陆县|