Polymorphism in Java

Polymorphism refers to the ability of an object to behave differently to the same message.

Polymorphism is of two types. static or dynamic. In dynamic polymorphism the response to message is decided on run-time while in static polymorphism it is decided out of run-time (i.e. on compile-time).

The assignment of data types in dynamic polymorphism is known as late or dynamic binding. In dynamic binding method call occur based on the object (instance) type at Run time. Eg: method overriding

If the assignment of data types is in compile time it is known as early or static binding. In static binding method call occur based on the reference type at compile time. Eg: method overloading

Method Overloading

Method overloading means creating a new method with the same name and different signature. It uses early binding.

Method Overriding

Method overriding is the process of giving a new definition for an existing method in its child class. All object created at run time on the heap therefore actual binding is done at the runtime only

Did you like this? If so, please
tell a friend
about it, and subscribe to the blog RSS feed.

Share/Save/Bookmark

If you enjoyed this post, make sure you subscribe to my RSS feed!




One Response to “Polymorphism in Java”  

  1. 1 Tara

    Good explanation. Thanks

Leave a Reply