मराठी

Explain multiple inheritance with the help of an example.

Advertisements
Advertisements

प्रश्न

Explain multiple inheritance with the help of an example.

कोड लेखन
स्पष्ट करा
Advertisements

उत्तर

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Inheritance - EXERCISE [पृष्ठ ७८]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×