1.

Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?(a) A.__init__(self)(b) B.__init__(self)(c) A.__init__(B)(d) B.__init__(A)The question was asked in homework.This is a very interesting question from Inheritance topic in portion Classes and Objects, Inheritance, Polymorphism, Encapsulation and Exception Handling of Python

Answer»

The CORRECT choice is (a) A.__init__(self)

EASY explanation - To INVOKE the __init__ method in A from B, either of the FOLLOWING should be written: A.__init__(self) or super().__init__(self).



Discussion

No Comment Found

Related InterviewSolutions