Python Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
56.
What is the purpose of the
__subclasses__()
method in Python classes?
Answer: Option
Explanation:
The
__subclasses__()
method is used to retrieve a list of all direct subclasses of a class.
57.
In Python, what is the purpose of the
__class__
attribute in an instance of a class?
Answer: Option
Explanation:
The
__class__
attribute is used to access the class of an instance in Python.
58.
What is the purpose of the
__metaclass__
attribute in a Python class definition?
Answer: Option
Explanation:
The
__metaclass__
attribute is used to specify a metaclass for the class, allowing customization of class creation and behavior.
59.
How can you achieve method overriding in Python using the
@staticmethod
decorator?
Answer: Option
Explanation:
Method overriding in Python can be achieved by using the
@staticmethod
decorator on the method in the superclass and implementing it in the subclass.
60.
What is the purpose of the
__bases__
attribute in Python classes?
Answer: Option
Explanation:
The
__bases__
attribute is used to access the base classes of a class in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers