What is polymorphism in regards to Object Oriented Programming (OOP)? Provide an example.
The word ‘polymorphism’ literally means ‘a state of having many shapes’ or ‘the capacity to take on different forms’. When applied to object oriented programming languages like Java, it describes a language’s ability to process objects of various types and classes through a single, uniform interface. For instance, let’s consider a class Vehicle and let Car be a subclass of Vehicle. So, any Car is a Vehicle. Here, Car satisfies the IS-A relationship for its own type as well as its super class Vehicle.
PR