Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 29)
29.
Consider the following Python code:
class Fruit:
def __init__(self, color):
self.color = color
class Apple(Fruit):
def __init__(self, color, variety):
super().__init__(color)
self.variety = variety
What is the purpose of `super().__init__(color)` in the `Apple` class?
Answer: Option
Explanation:
`super().__init__(color)` is used to call the constructor of the superclass (`Fruit` class) to initialize the `color` attribute of the `Apple` class.
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