Method Overriding in Python

In this article we want to learn about Method Overriding in Python, so method overriding

is used for changing the implementation of a method provided by one of it is parent or

base class.

 

 

OK let’s create our practical example on Method Overriding in Python

 

 

So in the above example we have two classes, the first class is our Person Class and

it is our base class, also we have added a method of def full_name() , on the other hand

we have another class at name of Student class and this class is extending from the base class,

so for this we can say that it is a derived class, now you can see that we have the same name

method in our derived class, when you have two methods with the same name and different

implementation that is called Method Overriding, and these two methods have their own

implementation, even tough they have the same name but the implementations are different.

 

 

 

 

 

If you run the code you can see that we have different implementation for the

same method name.

Method Overriding in Python
Method Overriding in Python

Leave a Comment