Class Inheritance Exercise
Question 1 of 5
What will be the output of this code?
class Animal:
def __init__(self, name):
self.name = name
def speak(self):
return f'{self.name} makes a sound'
class Cat(Animal):
def speak(self):
return f'{self.name} meows'
cat = Cat('Whiskers')
print(cat.speak())Error
Whiskers meows
Whiskers makes a sound
makes a sound