Given the following:
and this code fragment:
What is the outcome?
All three references have the runtime type Badminton, so each play() call invokes the overriding Badminton.play() method. Its super.play() call invokes InDoor.play(), which prints b , followed by Badminton.play() printing c ; this occurs three times. Java instance-method invocation is selected by the object's runtime class, while super invokes the superclass implementation. Java Language Specification, §15.12
Badminton
play()
Badminton.play()
super.play()
InDoor.play()
b
c
super
Community Discussion