4. Given the following Java code: [10 points]
10. interface A { public int getValue();}
11. class B implements A {
12. public int getValue() { return 1;}
13. }
14. class C extends B {
15. // insert code here16. }
What three code fragments individually at line 15, make used of polymorphism?
(Choose three)
(A) public void add (C c) {c.getValue();}
(B) public void add (B b) {b.getValue();}
(C) public void add (A a) {a.getValue();}
(D) public void add (A a, B b) {a.getValue();}
(E) public void add (C c1, C c2) {c1.getValue();}
ANS:__ (B), (C), (D)__
請問是否有人可以跟我解釋一下
為什麼答案是BCD嗎
我完全不了解這樣跟多形有什麼關係耶@@
拜託了~感謝萬分
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.168.193.40
推
05/04 22:59, , 1F
05/04 22:59, 1F
推
05/05 00:22, , 2F
05/05 00:22, 2F
推
05/05 22:59, , 3F
05/05 22:59, 3F
推
05/06 16:20, , 4F
05/06 16:20, 4F
討論串 (同標題文章)