Oops 2 11
Oops 2 11
Name=durga
Age=48
Rollno=101
Marks=90
Note: In the above example when ever we are creating child class object both parent and child
class constructors got executed to perform initialization of child object
Types of Inheritance:
1. Single Inheritance:
The concept of inheriting the properties from one class to another class is known as single
inheritance.
Eg:
1) class P:
2) def m1(self):
3) print("Parent Method")
4) class C(P):
5) def m2(self):
6) print("Child Method")
7) c=C()
8) c.m1()
9) c.m2()
Output:
Parent Method
Child Method
Single Inheritance
nd
DURGASOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
11 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www.durgasoft.com