Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 23)
23.
Consider the following Python code:
class Car:
def __init__(self, brand):
self.brand = brand
class ElectricCar(Car):
def __init__(self, brand, battery_capacity):
super().__init__(brand)
self.battery_capacity = battery_capacity
What is the purpose of using `super().__init__(brand)` in the `ElectricCar` class?
Answer: Option
Explanation:
`super().__init__(brand)` is used to call the constructor of the superclass (`Car` class) to 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