Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 61)
61.
Consider the following Python code:
class Person:
def __init__(self, name, __age):
self.name = name
self.__age = __age
def get_age(self):
return self.__age
What is the purpose of the get_age() method?
Answer: Option
Explanation:
The get_age() method is designed to retrieve the private variable __age, demonstrating encapsulation by providing controlled access.
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