Back to photostream

Polymorphism in Java

Polymorphism in Java is another important feature of OOPs concept. We have seen an overview of polymorphism in the tutorial OOPs concepts in Java. In this tutorial, we will understand in detail about polymorphism and its different types. We will cover about Static Polymorphism, Dynamic Polymorphism, Runtime Polymorphism.

What is polymorphism in Java

Polymorphism in Java as the name suggests means the ability to take multiple forms. It is derived from the Greek words where Poly means many and morph means forms. In Java, polymorphism in java is that the same method can be implemented in different ways. To understand this, we need to have an idea of inheritance in java as well which we have learned in the previous tutorial.

Types of Polymorphism in Java

Below are the different types of polymorphism in java.

 

Static Polymorphism

When we overload a static method, we call it as static polymorphism. Since it resolves the polymorphism during compile time, we can call also name it as compile-time polymorphism. We can implement this type of polymorphism in java using either method overloading or operator overloading. In static polymorphism, during compile time it identifies which method to call based on the parameters we pass.

 

Let's understand this in detail with the help of examples.

Method overloading

When there are many methods with the same name but different implementations, we call it a method overloading.

 

www.tutorialcup.com/java/polymorphism-in-java.htm

130 views
0 faves
0 comments
Uploaded on September 20, 2021