Advertisements
Advertisements
प्रश्न
Explain the significance of super() function.
कोड लेखन
स्पष्ट कीजिए
Advertisements
उत्तर
super() is used in a derived class to access methods of its parent class, especially the parent constructor.
class Student(Person):
def __init__(self, name, roll_no):
super().__init__(name)
self.roll_no = roll_no
It avoids repeating parent-class code and is especially useful in multilevel inheritance.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
