Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 97)
97.
Consider the following Python code:
class Triangle:
def __init__(self, __base, __height):
self.__base = __base
self.__height = __height
def calculate_area(self):
return 0.5 * self.__base * self.__height
What is the purpose of the calculate_area() method?
Answer: Option
Explanation:
The calculate_area() method calculates and returns the area of the triangle, 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