Python Programming - Inheritance - Discussion
Discussion Forum : Inheritance - General Questions (Q.No. 87)
87.
Consider the following code:
class Vehicle:
def __init__(self, brand):
self.brand = brand
class Car(Vehicle):
def __init__(self, brand, model):
super().__init__(brand)
self.model = model
What is the primary purpose of using super().__init__(brand)
in the Car
class constructor?
Answer: Option
Explanation:
super().__init__(brand)
is used to call the constructor of the superclass Vehicle
and initialize the brand
attribute.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers