Python - Polymorphism and Dynamic Behavior
What will be the output of this code?
class Animal:
def sound(self):
return "Some sound"
class Dog(Animal):
def sound(self):
return "Bark"
class Cat(Animal):
def sound(self):
return "Meow"
animals = [Dog(), Cat(), Animal()]
for a in animals:
print(a.sound())