Click the Exhibit button. 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?

  1. go in Goban go in Sente go in Sente

  2. go in Sente go in Sente go in Goban

  3. go in Sente go in Goban go in Goban

  4. D. go in Goban go in Goban go in Sente


Correct Option: C

AI Explanation

To answer this question, let's go through the code step by step:

  1. The GoTest class is defined as the public class.
  2. The main method is defined, which is the entry point of the program.
  3. An instance of the Sente class is created and its go method is called.
  4. An instance of the Goban class is created and its go method is called.
  5. An instance of the Stone class is created and its go method is called.
  6. The GoTest program ends.

Now, let's analyze each class and its go method:

  • The Sente class implements the Go interface and overrides its go method to print "go in Sente."
  • The Goban class extends the Sente class and overrides its go method to print "go in Goban."
  • The Stone class extends the Goban class but does not override the go method.

Based on the code and the class hierarchy, the order of method calls will be as follows:

  1. a.go() (from Sente class) will print "go in Sente."
  2. b.go() (from Goban class) will print "go in Goban."
  3. c.go() (from Goban class, since Stone does not override go) will also print "go in Goban."

Therefore, the correct answer is option C: "go in Sente go in Goban go in Goban."

Find more quizzes: