Python Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
21.
In Python, what is the purpose of the
__init_subclass__()
method?
Answer: Option
Explanation:
The
__init_subclass__()
method is called when a new subclass is created, allowing customization of the creation process.
22.
How does Python handle circular dependencies in the context of inheritance?
Answer: Option
Explanation:
Python requires explicit handling of circular dependencies using techniques like late imports or rearranging code.
23.
What is the purpose of the
__slots__
attribute in a Python class?
Answer: Option
Explanation:
The
__slots__
attribute restricts the attributes that can be dynamically added to instances, improving memory efficiency.
24.
What is the purpose of the
@property
decorator?
Answer: Option
Explanation:
The
@property
decorator is used to define a property in a class, allowing the use of the property like an attribute.
25.
What is the purpose of the
__del__()
method in Python classes?
Answer: Option
Explanation:
The
__del__()
method is called when an instance of a class is about to be destroyed, providing an opportunity for cleanup operations.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers