What is the purpose of the super() function in Python?
Correct answer
A. Call a parent class method
14 views
A. Call a parent class method
14 views
super() is used to call a method of the parent class from a child class. The commonest use is super().__init__() inside a subclass constructor, so the parent's initialisation still runs.
It avoids hard-coding the parent's name and follows the method resolution order, which matters with multiple inheritance.
For more solved questions like this one, see Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.