Question 1
Back to Exercise
What is the output of the following Python program?
class Animal:
def speak(self):
return "sound"
class Dog(Animal):
def speak(self):
return "Woof and " + super().speak()
print(Animal().speak(), "|", Dog().speak())
- A sound | Woof
- B sound | sound
- C sound | Woof and sound Correct
- D RecursionError
Correct Answer: Option C
super().speak() calls the parent version from inside the override.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!