Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 83)
83.
What is the primary purpose of the following Python class?
class Wallet:
def __init__(self, owner, __balance):
self.owner = owner
self.__balance = __balance
def get_balance(self):
return self.__balance
Answer: Option
Explanation:
The get_balance() method provides controlled and read-only access to the private variable '__balance', 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