Polymorphism in Java

Polymorphism means more than one form, same object performing different operations according to the requirement.


Types of Polymorphism in Java:
There are following two type polymorphism in java.

1. Run Time Polymorphism(Method overriding)
2. Compile Time Polymorphism(Method overloading)


Polymorphism can be achieved by using two ways, those are

  1. Method overriding
  2. Method overloading

Method overloading means writing two or more methods in the same class by using same method name, but the passing parameters is different.

Method overriding means we use the method names in the different classes,that means parent class method is used in the child class.

In Java to achieve polymorphism a super class reference variable can hold the sub class object.

To achieve the polymorphism every developer must use the same method names in the project.

Related Articles

post a comment