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