Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 26)
26.
Consider the following Python code:
class CustomClass:
def __init__(self, value):
self.__value = value
def get_value(self):
return self.__value
obj = CustomClass(42)
result = obj.get_value()
print(result)
What will be the value of result
?
Answer: Option
Explanation:
The private attribute
__value
is accessed through the public method get_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