Explain Polymorphism.

Polymorphism is the ability for an object to change its behavior according to how it is being used. Where an object’s class inherits from a super-class or implements one or more interfaces, it can be referred to by those class or interface names. So if we have a method that expects an object of type ‘vehicle’ to be passed as a parameter, we can pass any vehicle, car or motorcycle object to that method even though the data type may be technically different.

Tagged . Bookmark the permalink.

Leave a Reply