2009年2月11日 星期三

第75題

Given:
11. public interface A{ public void m1(); }
13. class B implements A{ }
14. class C implements A{ public void m1(){}}
15. class D implements A{ public void m1(int x){}}
16. abstract class E implements A {}
17. abstract class F implements A { public void m1(){} }
18. abstract class G implements A { public void m1(int x){} }
What is the result?
A. Compilation succeeds.
B. Exactly one class does NOT compile.
C. Exactly two classes do NOT compile.
D. Exactly four classes do NOT compile.
E. Exactly three classes do NOT compile.
答案:C
參考:7-6 介面

----------------------------------------------------------

13. class B implements A{ } // 實作了介面A就必須把A的抽象方法實作出來.
15. class D implements A{ public void m1(int x){}} // m1的參數不同,所以不是實作.

1 則留言: