• Entries (RSS)
  • Comments (RSS)

Polymorphism in Java

Posted by | Posted in Java | Posted on 22-10-2007

Tagged Under : ,

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

Share

Most commented

Comments

1 comments posted onPolymorphism in Java

  1. Good explanation. Thanks

Post a Comment