38 overriding in python

 


'''

1. If you have same method names in class A and class B, 

then if you Inheritence class A into class B 

then Class A method will override with class B method.

'''

class A():

    def add(self):

        print('\n A ADD ')


class B():

    def add(self):

        print('\n B ADD ')


class C(B, A):

    def add(self):

        print(' \n C ADD ')


inst = C()

inst.add()


Comments

Popular posts from this blog

1 PYTHON PROGRAMMING

16 file handling in python

4 Tuple data types