Examveda

What is the purpose of the __eq__() method in Python classes?

A. To create an instance of a class

B. To compare two instances for equality

C. To modify object attributes

D. To convert an object to a string

Answer: Option B

Solution (By Examveda Team)

The __eq__() method defines how instances of a class are compared for equality using the == operator.

This Question Belongs to Python Program >> Advanced OOP Concepts

Join The Discussion

Related Questions on Advanced OOP Concepts

What is inheritance in OOP?

A. Creating new objects from existing ones

B. Allowing objects to share attributes and methods

C. Restricting access to object attributes

D. Converting classes into objects