?
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。記住一句話,成員變量(編譯時(shí))看左邊,方法(運(yùn)行時(shí))看右邊。
posted on 2006-04-13 08:57
小小程序程序員混口飯吃 閱讀(929)
評(píng)論(1) 編輯 收藏 所屬分類(lèi):
java