Advertisements
Advertisements
Question
Explain multiple inheritance with the help of an example.
Code Writing
Explain
Advertisements
Solution
In multiple inheritance, a child class inherits features from more than one parent class.
class Father(object):
def father_name(self):
print("Father: Raj")
class Mother(object):
def mother_name(self):
print("Mother: Rani")
class Child(Father, Mother):
pass
c = Child()
c.father_name()
c.mother_name()
Child can access methods of both Father and Mother.
shaalaa.com
Is there an error in this question or solution?
