Python Programming - Encapsulation - Discussion

Discussion Forum : Encapsulation - General Questions (Q.No. 93)
93.
Consider the following Python code:
class Rectangle:
    def __init__(self, __length, __width):
        self.__length = __length
        self.__width = __width

    def calculate_area(self):
        return self.__length * self.__width
What is the purpose of the calculate_area() method?
To retrieve the area of the rectangle
To set a new area for the rectangle
To calculate the area of the rectangle
To expose all internal details of the class
Answer: Option
Explanation:
The calculate_area() method calculates and returns the area of the rectangle, demonstrating encapsulation.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.