Essential features of object oriented programming:-
- Data Encapsulation
- Inheritance
- Overriding
- Polymorphism
Overriding- Overriding is the feature which lets you define a parent class method. Like the name suggests, you can overriding a parent class function or a method in the child class.
Following conditions must be met for overriding a function:
- Inheritance should be there. Function overriding cannot be done within a class. We need to derive a child class from a parent class.
- The function that is redefined in the child class should have the same signature as in the parent class i.e. same number of parameters.
e.g.,
class company1(): def employee(self, a): print("This is a parent class.") class company2(a): def employee(self): print("Employees work") a=company2() a.employee()
Output- Employees work

This is all about overriding in python.