Python Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
26.
What is the purpose of the
__getattr__()
method?
Answer: Option
Explanation:
The
__getattr__()
method is called when attempting to access an undefined attribute, allowing customization of attribute access.
27.
In Python, what is the purpose of the
__getattribute__()
method?
Answer: Option
Explanation:
The
__getattribute__()
method is called for all attribute access, providing a way to customize attribute access behavior.
28.
What is a metaclass?
Answer: Option
Explanation:
A metaclass in Python is a class used to create and customize the behavior of class instances, allowing modification of class creation and initialization.
29.
How does Python handle name mangling for attributes in a class?
Answer: Option
Explanation:
Attributes with a double leading underscore in Python undergo name mangling, which involves adding a prefix based on the class name to avoid naming conflicts.
30.
How can you achieve method overriding in Python without using the
super()
function?
Answer: Option
Explanation:
Method overriding in Python can be achieved by redefining a method in the subclass with the same name as in the superclass.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers