Python Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
41.
What is the purpose of the
__setattr__()
method in Python classes?
Answer: Option
Explanation:
The
__setattr__()
method is used to customize the behavior when setting an attribute on an instance of a class.
42.
In Python, what is the purpose of the
@property
decorator for methods?
Answer: Option
Explanation:
The
@property
decorator is used to define a method that can be accessed like an attribute, allowing it to be called without parentheses.
43.
How does Python support method overloading?
Answer: Option
Explanation:
Python does not support method overloading in the traditional sense, as methods with the same name in a class will override each other.
44.
What is the purpose of the
__doc__
attribute in Python classes?
Answer: Option
Explanation:
The
__doc__
attribute is used to provide documentation (docstring) for a class, describing its purpose and usage.
45.
How can you achieve method overloading in Python using default values?
Answer: Option
Explanation:
Method overloading in Python can be achieved by defining multiple methods with different numbers of parameters and providing default values for some parameters.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers