随笔-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 小小程序程序员混口饭吃 阅读(926) 评论(1)  编辑  收藏 所属分类: java

评论:
# re: JAVA动态绑定 2007-07-03 14:46 | itkui
向上转型吧。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: