Python Inheritance Questions and Answers
Practice ModeShowing 10 of 25 questions
Q1
What is inheritance in Python?
Answer: Option A
Explanation: Inheritance allows a class to inherit attributes and methods from another class.
Q2
Which keyword is used for inheritance in Python?
Answer: Option D
Explanation: The "class ChildClass(ParentClass):" syntax is used for inheritance in Python.
Q3
What is the parent class of all classes in Python?
Answer: Option A
Explanation: In Python, all classes implicitly inherit from the object class.
Q4
Which method is called when a child class overrides a parent class method?
Answer: Option B
Explanation: The child class method overrides the parent class method when both have the same name.
Q5
What is method overriding in inheritance?
Answer: Option B
Explanation: Method overriding allows a child class to provide a specific implementation of a method that is already defined in its parent class.
Q6
How can you call a parent class method from a child class?
Answer: Option B
Explanation: The super() function is used to call methods from the parent class in the child class.
Q7
What is multiple inheritance in Python?
Answer: Option B
Explanation: Multiple inheritance allows a class to inherit from more than one parent class.
Q8
What is the purpose of the __init__ method in inheritance?
Answer: Option A
Explanation: The __init__ method is called when an object is created and can be overridden in child classes.
Q9
What is hierarchical inheritance?
Answer: Option C
Explanation: Hierarchical inheritance occurs when multiple child classes inherit from a single parent class.
Q10
What is multilevel inheritance?
Answer: Option C
Explanation: Multilevel inheritance occurs when a child class inherits from a parent class, which itself inherits from another class.