Python Programming - Encapsulation - Discussion

Discussion Forum : Encapsulation - General Questions (Q.No. 101)
101.
Consider the following Python code:
class Square:
    def __init__(self, __side_length):
        self.__side_length = __side_length

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

Post your comments here:

Your comments will be displayed after verification.