हिंदी

What is multiple inheritance? Explain with an example.

Advertisements
Advertisements

प्रश्न

What is multiple inheritance? Explain with an example.

कोड लेखन
स्पष्ट कीजिए
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 4: Inheritance - EXERCISE [पृष्ठ ७७]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 4 Inheritance
EXERCISE | Q 4. | पृष्ठ ७७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×