例題 032
1. class Mammal{} 2. 3. class Raccoon extends Mammal { 4. Mammal m = new Mammal(); 5. } 6. 7. class BabyRaccoon extends Mammal{} Which four statements are true? (Choose four.)[1] A. Raccoon is-a Mammal. B. Raccoon has-a Mammal. C. BabyRaccoon is-a Mammal. D. BabyRaccoon is-a Raccoon. E. BabyRaccoon has-a Mammal. F. BabyRaccoon is-a BabyRaccoon.
[1] http://192.192.246.169/~wells/wiki/index.php/SCJP_1.6%E7%89%88%E8%80%83%E9%A1%8C_032
這題我選 ABC (E),
看來繼承之後附類別的物件不能算式子類別的, not has-a,
而自己也可以是自己, 雖然很怪.
之後看到在來更新一下XD
- - - - - - - - - -
例題 034
Which four statements are true? (Choose four.)[2] 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.
網站的中文說明
那四個敘述是正確的? A. Has-a 關係應該永遠不能被封裝 B. Has-a 關係應該以繼承的方式實作 C. Has-a 關係可以用物件變數的方式被實現出來 D. Is-a關係可用extends關鍵字實現出來 E. Is-a關係可用implements關鍵字實現出來 F. 電影和女演員間的關係是一個Is-a關係的例子 G. 一個陣列或一個集合可以被用來實作一對多的has-a關係
[2] http://192.192.246.169/~wells/wiki/index.php/SCJP_1.6%E7%89%88%E8%80%83%E9%A1%8C_034
A. Has-a 可以被封裝.
B. Has-a 不可用繼承方式實做.
C. Has-a 可以用實做變數來實現.
D. Is-a 可以用繼承來實現.
E. Is-a 可以用implements實現.
F. 電影和女演員的關係是Has-a的關係.
G. 陣列和集合可被一對多的Has-a實現.
沒有留言:
張貼留言