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?
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers