第四十六題: |
Given: public class Pizza { And: class PepperoniPizza extends Pizza { Pizza pizza = new PepperoniPizza(); |
What is the result? A. Compilation fails. |
答案:以更正於2012/01/19,感謝范棛祺提醒 A |
執行結果:答案中 |
題目範圍:物件觀念 |
解析: 英文解釋:Pepperoni 義大利辣味香腸(好吃),Mushroom 蘑菇 如果方法被定為final,那麼就表示被繼承之後就不可以覆寫,但還是可以多載 請注意變數與方法被標記為final時限制的不同點 |
第四十七題(拖拉題): |
|||||||||||||||||||||||||
Place the Types in one of the Type columns, and the Relationships in the Relationship column, to define appropriate has-a and is-a relationships:
Relationship
Types
|
|||||||||||||||||||||||||
答案:題目反白 |
|||||||||||||||||||||||||
執行結果:無 |
|||||||||||||||||||||||||
題目範圍:物件觀念 |
|||||||||||||||||||||||||
解析: 以生活實例來表現物件觀念的題目 有些人可能會填入Book has-a Programming Book,不過這樣是不對的,書本裡面並沒有另外一種書,而可能是紙、文字、書籤等等 has-a 和is-a 並不是相反的關係,不要混淆 |
第四十八題: |
Given: public class Venus { |
What is the result? A. 1 |
答案:C |
執行結果:答案中 |
題目範圍:for迴圈列舉法 |
解析: 這題只要抓住傳遞參數的型態,就很容易可以解出來 go() 方法中 |
第四十九題(拖拉題): |
||||||
Given: public int update(int quantity, int adjust) { quantity = quantity + adjust; return quantity; _ }
public void callUpdate() { int quant = 100; quant = update(quant, 320); System.out.println("The quantity is " + quant); }
Code Fragments
|
||||||
答案:題目反白 |
||||||
執行結果:無 |
||||||
題目範圍:基本觀念 |
||||||
解析: 方法在傳遞基本資料型態時,傳遞的是值而不是指標 |
第五十題: |
Given: public abstract class Shape { |
Which two classes use the Shape class correctly? (Choose two.) A. public class Circle implements Shape{ B. public abstract class Circle extends Shape{ C. public class Circle extends Shape{ D. public abstract class Circle implements Shape{ E. public class Circle extends Shape{ F. public abstract class Circle implements Shape{ } |
答案:BE |
執行結果:無 |
題目範圍:abstract class |
解析: Interface 才是用implements 關鍵字 不論是繼承抽象類別還是一般類別,子代都可以被設定成抽象類別 Abstract這個單字的意思是抽象,抽象並不是模糊不清的意思,而是精隨的意思 |
留言列表