隨筆-109  評論-187  文章-25  trackbacks-0
          ?
          19: ? ? class A {
          public int getNumber(int a) {
          ? ? return a + 1;
          }
          ? ? ? ? }
          ?
          ? ? ? ? class B extends A {
          public int getNumber (int a) {
          return a + 2;
          ? ? ? ? }
          ?
          public static void main (String args[]) ?{
          A a = new B();
          14. System.out.printIn(a.getNumber(0));
          15. ? ?}
          16. } ?
          What is the result?
          A. Compilation succeeds and 1 is printed.
          B. Compilation succeeds and 2 is printed.
          C. An error at line 8 causes compilation to fail.
          D. An error at line 13 causes compilation to fail.
          E. An error at line 14 causes compilation to fail.
          Answer:B。記住一句話,成員變量(編譯時)看左邊,方法(運行時)看右邊。
          posted on 2006-04-13 08:57 小小程序程序員混口飯吃 閱讀(932) 評論(1)  編輯  收藏 所屬分類: java

          評論:
          # re: JAVA動態(tài)綁定 2007-07-03 14:46 | itkui
          向上轉(zhuǎn)型吧。  回復(fù)  更多評論
            
          主站蜘蛛池模板: 德令哈市| 武乡县| 寻乌县| 郑州市| 山丹县| 武强县| 翁源县| 凤冈县| 达尔| 鄂伦春自治旗| 静乐县| 安义县| 黄山市| 湖南省| 汉寿县| 莲花县| 周口市| 陈巴尔虎旗| 舒兰市| 天气| 宾阳县| 双鸭山市| 芒康县| 彭泽县| 广安市| 珲春市| 兴海县| 阿城市| 永川市| 通州区| 宜阳县| 彭山县| 孟连| 商都县| 莲花县| 方城县| 盐边县| 沾益县| 安龙县| 蒲江县| 太湖县|