16~20題考的都是JAVA重要的觀念
務必弄懂才繼續做下去
第十六題: |
Given: class Atom { |
What is the result? A. Compilation fails. |
答案:F |
執行結果:答案中 |
題目範圍:物件觀念 |
解析: 這題的觀念非常的核心,如果不太瞭解一定要想辦法弄懂 這題中,Atom類別沒有明講繼承的對象,那麼預設就會是繼承了Object 類別 類題:十八題、二十八題、三十七題 |
第十七題: |
Given: 1. public
class Blip{ |
Which five methods, inserted independently at line 5, will compile? (Choose five.) A. public int blipvert(int x){return 0;} B. private int blipvert(int x){return 0;} C. private int blipvert(long x){return 0;} D. protected long blipvert(int x){return 0;} E. protected int blipvert(long x){return 0;} F. protected long blipvert(long x){return 0;} G. protected long blipvert(int x, int y){return 0;} |
答案:ACEFG |
執行結果:無 |
題目範圍:物件觀念 |
解析: 繼承方法的限制,第十二題拖拉題就有出現過 請參閱:第十二題 |
第十八題: |
Given: 1. class Super{ |
Which two, independently, will allow Sub to compile? (Choose two.) A. Change line 2 to: B. Change line 2 to: C. Change line 13 to: D. Change line 13 to: E. Change line 13 to: |
答案:CD |
執行結果:無 |
題目範圍:物件觀念 |
解析: 選項B看似是正確的,不過還差了一點,因為這樣的話第13行的建構子會因為缺少父代的無引數建構子而產生編譯錯誤 |
第十九題: |
Which Man class properly represents the relationship "Man has a best friend who is a Dog"? A. class Man extends Dog{} B. class Man implements Dog{} C. class Man{private BestFriend dog;} D. class Man{private Dog bestFriend;} E. class Man{private Dog<bestFriend>;} F. class Man{private BestFriend<dog>;} |
答案:D |
執行結果:無 |
題目範圍:物件觀念 |
解析: A. class Man extends Dog{} 這麼說的話就是"人是狗的一種",太可怕了@@ B. class Man implements Dog{} 人用了狗的功能,不是吧 =_= C. class Man{private BestFriend dog;} 好朋友是狗,不對 D. class Man{private Dog bestFriend;} 狗是好朋友,正確 E. class Man{private Dog<bestFriend>;} 狗是好朋友組成的集合,錯 F. class Man{private BestFriend<dog>;} 好朋友是狗組成的集合,錯 |
第二十題: |
A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting? A. Looser coupling B. Tighter coupling C. Lower cohesion D. Higher cohesion E. Weaker encapsulation |
答案:AD |
執行結果:無 |
題目範圍:物件觀念 |
解析: 如果你是初識JAVA的人,你看到OO一定會想:O_O什麼是OO?
請參閱:
|
留言列表