Advertisements
Advertisements
Question
What is multiple inheritance? Explain with an example.
Code Writing
Explain
Advertisements
Solution
Multiple inheritance occurs when one derived class inherits from two or more base classes.
class Student(object):
def student_info(self):
print("Student details")
class Teacher(object):
def teacher_info(self):
print("Teacher details")
class School(Student, Teacher):
pass
s = School()
s.student_info()
s.teacher_info()
Here, School inherits methods from both Student and Teacher.
shaalaa.com
Is there an error in this question or solution?
