Python Programming - Classes - Discussion

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

class Rectangle(Shape):
    def __init__(self, length, width):
        self.length = length
        self.width = width
    
    def area(self):
        return self.length * self.width
What principle of object-oriented programming is applied here?
Abstraction
Polymorphism
Encapsulation
Inheritance
Answer: Option
Explanation:
The code illustrates the principle of inheritance, where the `Rectangle` 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:

Your comments will be displayed after verification.