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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
