OOP Concept: Polymorphism

Polymorphism means the ability to take more than one form.

For example, an operation may exhibit different behaviour in different instances.


  1. A method defined in a class is inherited by all descendants of that class
  2. When a message is sent to an object to use method draw() , any messages that draw() sends will also be sent to the same object
  3. If the object receiving a message does not a have definition of the method requested, an inherited definition is invoked
  4. If the object receiving a message has a definition of the requested method, that definition is invoked

Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface. This means that a general class of operations may be accessed in the same manner even though specific actions associated with each operation may differ.

Any Java object that can pass more than one IS-A test can be considered polymorphic. Other than object of types of type Object, all java objects are polymorphic in that they pass the IS-A test of their own type and for class Object.

Polymorphism is extensively used in implementing inheritance. In Java, a class cannot extend more than one class. That means one parent per class. However a class can have multiple ancestors. For example, class B can extend class A and class C can extend class B, and so on. So any given class might have multiple classes up its inheritance tree.

OOP Concept: Polymorphism

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s