Python Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 18)
18.
Consider the following code:
class Shape:
    def area(self):
        pass

class Triangle(Shape):
    def area(self, base, height):
        return 0.5 * base * height

class Square(Shape):
    def area(self, side):
        return side * side
What concept is demonstrated in this code?
Operator overloading
Method overloading
Method overriding
Polymorphism
Answer: Option
Explanation:
This code demonstrates method overloading, where the subclass methods have the same name but different parameters than the superclass method.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.