Big Data and Hadoop Training @$80 or Rs. 6,000 only - valid till Oct 17th Apply Now!

What is Polymorphism in Java?

Ads
 

What is Polymorphism in Java?

Polymorphism in Java is part of OOPs concept that helps an object to decide which method implementation to be executed after receiving a method call.

Polymorphism in Java is part of OOPs concept that helps an object to decide which method implementation to be executed after receiving a method call.

Polymorphism in Java means a subclass, though having its own unique behavior, can also share some functionality of its parent class. It is a part of (Object Oriented Programing) OOPs concept that allows object of various types to define a common interface of operations.

Any object that satisfies more than one IS-A relationship is polymorphic. In Polymorphism, common interface is used while writing code. Single polymorphism is achieved by method overriding while multiple polymorphism is when an abstract class uses another abstract class.

In simple words Polymorphism in Java helps an object to decide which method implementation to be executed after receiving a method call.

If we use a common interface it becomes easy to change code to support new implementation.

Polymorphism in Java can be seen through Inheritance, method overloading and method overriding.

In Compile-Time polymorphism uses method signatures to determine which among various methods to be executed after compilation to the byte code.

In Run-Time polymorphism, achieved through overridden methods, a computer does not know which methods to execute till the run time.

Ads

Ads