Method Overriding Exercise
Question 1 of 4
What happens when a child class defines a method with the same name as a parent method?
class Animal:
def speak(self):
return "Animal makes a sound"
class Dog(Animal):
def speak(self):
return "Dog barks"
dog = Dog()
print(dog.speak()) # What is printed?"Dog barks"
Both messages are printed
"Animal makes a sound"
An error occurs due to method conflict