Python Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
31.
In Python, what is the purpose of the
__call__()
method in a class?
Answer: Option
Explanation:
The
__call__()
method is called when an instance of a class is used as a function, allowing instances to be callable.
32.
What is the purpose of the
__eq__()
method in Python classes?
Answer: Option
Explanation:
The
__eq__()
method is used to customize the equality comparison between instances of a class.
33.
How can you prevent a class in Python from being inherited by other classes?
Answer: Option
Explanation:
In Python, a class can be prevented from being inherited by using the
@final
decorator.
34.
What is the purpose of the
__len__()
method in Python classes?
Answer: Option
Explanation:
The
__len__()
method is used to customize the behavior of the len()
function for instances of a class.
35.
What is the purpose of the
@abstractmethod
decorator?
Answer: Option
Explanation:
The
@abstractmethod
decorator is used to define an abstract method in a class, which must be implemented by any concrete subclasses.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers