Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 69)
69.
How can encapsulation be enhanced in the following Python class to provide write access to the 'price' variable?
class Product:
def __init__(self, name, price):
self.name = name
self.__price = price
Answer: Option
Explanation:
To provide write access to a private variable, a setter method can be created for 'price'.
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