Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 18)
18.
Consider the following Python code:
class CustomClass:
def __init__(self, value):
self.value = value
def __eq__(self, other):
return self.value == other.value
obj1 = CustomClass(10)
obj2 = CustomClass(10)
result = obj1 == obj2
print(result)
What will be the value of result
?
Answer: Option
Explanation:
The custom
__eq__
method is defined to compare the value
attribute of the objects.
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