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?
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers