In this we are going to see a program on multilevel inheritance of constructor in Python Programming Language.
class classOne:
def __init__(self):
print('Initialized classOne')
def printSt(self, num):
print('Printing from classOne:', num)
class classTwo(classOne):
def __init__(self):
print('Initialized classTwo')
super().__init__()
def printSt(self, num):
print('Printing from classTwo:', num)
super().printSt(num + 1)
class classThree(classTwo):
def __init__(self):
print('Initialized classThree')
super().__init__()
def printSt(self, num):
print('Printing from classThree', num)
super().printSt(num + 1)
# main function
if __name__ == '__main__':
obj = classThree()
obj.printSt(10)
# Coded By Dhiraj Shelke
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP