Python Programming - Polymorphism - Discussion
Discussion Forum : Polymorphism - General Questions (Q.No. 36)
36.
Consider the following code:
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
def __eq__(self, other):
return self.title == other.title and self.author == other.author
What concept is demonstrated in this code?
Answer: Option
Explanation:
This code demonstrates operator overloading using the
__eq__()
method to customize the behavior of the equality operator (==
) for instances of the class.
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