ExamVeda
Login
Home
21
What is the purpose of the __eq__() method in Python classes?
Discuss
Answer & Solution
Answer: Option B
Solution:
The __eq__() method defines how instances of a class are compared for equality using the == operator.
22
What is the diamond problem in multiple inheritance?
Discuss
Answer & Solution
Answer: Option C
Solution:
The diamond problem refers to the ambiguity that arises when a class inherits from two classes that have a common ancestor.
23
What is the role of the @abstractmethod decorator in advanced OOP?
Discuss
Answer & Solution
Answer: Option C
Solution:
The @abstractmethod decorator indicates that a method must be overridden in subclasses.
24
How can you implement method overloading in Python?
Discuss
Answer & Solution
Answer: Option A
Solution:
Method overloading is achieved by defining multiple methods with the same name but different parameters.
25
What is the purpose of the super() function in advanced OOP?
Discuss
Answer & Solution
Answer: Option A
Solution:
The super() function is used to call the constructor of the base class in a subclass.