Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 62)
62.
How can encapsulation be achieved in Python to provide read-only access to a variable?
class Example:
def __init__(self):
self.__value = 42
Answer: Option
Explanation:
To provide read-only access to a variable, a getter method can be created to retrieve the value.
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