Python Inheritance Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
Can we inherit from built-in types like list or dict?
Answer: Option B
Explanation: Yes, Python allows inheriting from built-in types to create customized versions.
Q22
What is method overloading in Python?
Answer: Option A
Explanation: Python doesn't support traditional method overloading, but we can use default arguments or variable arguments.
Q23
What is composition in OOP?
Answer: Option B
Explanation: Composition is an alternative to inheritance where a class contains objects of other classes.
Q24
When to use inheritance vs composition?
Answer: Option C
Explanation: Use inheritance for "is-a" relationships and composition for "has-a" relationships.
Q25
What is the output of: print(issubclass(bool, int))
Answer: Option A
Explanation: In Python, bool is a subclass of int. True and False are instances of bool which is a subclass of int.