Polymorphism literally means multiple forms. In world of SAP, it stands for implementation of different methods of different subclasses inherited from a same parent behaving differently. It facilitated same functionality on different objects resulting in different results.
Let’s get back to Vehicle example from previous post on Inheritance.
Vehicle itself is a parent class (superclass) which has three child classes (subclasses)- two wheelers, light four wheelers and heavy four wheelers. Each inherits a method called Insurance which is based on depreciating cost of vehicle and points on driver’s record. It holds good for two wheelers and light four wheelers but heavy four wheelers come with a rider – a damage surcharge because of heavy four wheelers’ ability to cause bigger crash. This rider can be added to the method implementation in sub class for heavy four wheelers. This is an example of polymorphism.
When the method insurance is called, it gets called based on the object and hence the insurance value differs for heavy four wheelers given rest of the parameters being same. It helps developers avoid complex condition structures and rely on object property only and hence, handling the functionality at source.