Python Programming - Inheritance - Discussion
Discussion Forum : Inheritance - General Questions (Q.No. 92)
92.
Consider the following code:
class Shape:
def __init__(self, color):
self.color = color
class Square(Shape):
def __init__(self, color, side_length):
super().__init__(color)
self.side_length = side_length
What is the primary advantage of using super().__init__(color)
in the Square
class constructor?
Answer: Option
Explanation:
super().__init__(color)
is used to call the constructor of the superclass Shape
and initialize the color
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