Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 65)
65.
Consider the following Python class:
class BankAccount:
def __init__(self, balance):
self._balance = balance
@property
def balance(self):
return self._balance
What does the @property decorator do in this code?
Answer: Option
Explanation:
The @property decorator is used to create a read-only property 'balance', providing controlled access to the private variable '_balance'.
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