SCJP題庫第038題
1. class One{
2. public One foo(){return this;}
3. }
4. class Two extends One{
5. public One foo(){return this;}
6. }
7. class Three extends Two{
8. //insert method here
9. }
Which two methods, inserted
individually, correctly complete
the Three class? (Choose two.)
A. public void foo(){}
B. public int foo(){return 3;}
C. public Two foo(){return this;}
D. public One foo(){return this;}
E. public Object foo(){return this;}
Ans:C D
解說:
overriding
比較要注意的是C為何可以,是因為Two is One(繼承關係)
Comments