1. public class GoTest {
2. public static void main(String[] args) {
3. Sente a = new Sente(); a.go();
4. Goban b = new Goban(); b.go();
5. Stone c = new Stone(); c.go();
6. }
7. }
8.
9. class Sente implements Go {
10. public void go() { System.out.println(”go in Sente.”); }
11. }
12.
13. class Goban extends Sente {
14. public void go() { System.out.println(”go in Goban”); }
15. }
16.
17. class Stone extends Goban implements Go { }     //个人认为,没实现接口的方法,所以这里应该编译错误。18.
19. interface Go { public void go(); }
What is the result?
A. go in Goban
go in Sente
go in Sente
B. go in Sente
go in Sente
go in Goban
C. go in Sente
go in Goban
go in Goban
D. go in Goban
go in Goban
go in Sente
E. Compilation fails because of an error in line 17.
Answer: C

解决方案 »

  1.   

    class Stone extends Goban implements Go { }  
    但是你也继承了Goban ,但是Goban 已经实现好Go 接口
      

  2.   

    class Stone extends Goban implements Go { }  类STONE已经继承了类GOBAN,而GOBAN又实现了GO,在GOBAN 中已经存在了GO中的方法GO()
    那么STONE理所当然的从GOBAN中继承了GOBAN的GO(),所以已经存在了GO(),也就实现了GO.GO()呵呵,说的好象有的绕
      

  3.   

    个人认为 第十七行继承自Goban,Goban继承自Sente,Sente 实现了接口并给出了go方法的实现,也就是说,Stone从Sente中继承了一个go方法 但是他被从Goban中继承的go方法覆盖了 所以个人认为答案是 C