Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 28)
28.
Consider the following Python code:
class Shape:
def area(self):
pass
class Triangle(Shape):
def __init__(self, base, height):
self.base = base
self.height = height
def area(self):
return 0.5 * self.base * self.height
What principle of object-oriented programming is applied here?
Answer: Option
Explanation:
The code exemplifies the principle of inheritance, where the `Triangle` class inherits from the `Shape` class and provides a specific implementation of the `area` 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