Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 56)
56.
What is the primary purpose of encapsulating the 'balance' variable in the following Python class?
class BankAccount:
def __init__(self, balance):
self._balance = balance
def get_balance(self):
return self._balance
Answer: Option
Explanation:
Encapsulation is used to provide controlled access to variables, and in this case, it is applied to the 'balance' variable.
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