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?
Method overloading
Operator overloading
Method overriding
Polymorphism
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:

Your comments will be displayed after verification.