Python Programming - Encapsulation - Discussion

Discussion Forum : Encapsulation - General Questions (Q.No. 89)
89.
Consider the following Python code:
class Circle:
    def __init__(self, __radius):
        self.__radius = __radius

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

Post your comments here:

Your comments will be displayed after verification.