SCJP題庫第027題


10. class One{
11.   void foo(){}
12. }
13. class Two extends One{
14.   //insert method here
15. }
Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
A. int foo(){/* more code here */}
B. void foo(){/* more code here */}
C. public void foo(){/* more code here */}
D. private void foo(){/* more code here */}
E. protected void foo(){/* more code here */}

Ans:
B  C  E

解說:
Overriding rule 
回傳值型態必須要一樣 所以A
子類別覆載的方洲存取屬性必須比父類別覆載的方法存取屬性一樣或更開放,D

Comments

Popular posts from this blog

Android+Google Map API v3 Geocoding(地址轉經緯度度