Python - Polymorphism and Dynamic Behavior
What will be the output of this code?
class Shape:
def area(self):
return 0
class Square(Shape):
def __init__(self, side):
self.side = side
def area(self):
return self.side * self.side
shapes = [Shape(), Square(4)]
for shape in shapes:
print(shape.area())