SCJP 1.6版考題 034
出自 陳富國維基館
Which four statements are true? (Choose four.) A. Has-a relationships should never be encapsulated. B. Has-a relationships should be implemented using inheritance. C. Has-a relationships can be implemented using instance variables. D. Is-a relationships can be implemented using the extends keyword. E. Is-a relationships can be implemented using the implements keyword. F. The relationship between Movie and Actress is an example of an is-a relationship. G. An array or a collection can be used to implement a one-to-many has-a relationship.
解答
Ans: C D E G
解說:
那四個敘述是正確的? Has-a 關係應該永遠不能被封裝 Has-a 關係應該以繼承的方式實作 Has-a 關係可以用物件變數的方式被實現出來 Is-a關係可用extends關鍵字實現出來 Is-a關係可用implements關鍵字實現出來 電影和女演員間的關係是一個Is-a關係的例子 一個陣列或一個集合可以被用來實作一對多的has-a關係
|