POLYMORPHISM IN JAVA

 POLYMORPHISM



One name but multiple form is concept of polymorphism.
This allows us to perform a single action in different ways.

There are two types of polymorphism in Java:

 compile-time polymorphism and runtime polymorphism. 

We can perform polymorphism in java by method overloading and method overriding.


eg 1 - In a class method name is same ,but we can apply different type of argument

is called method overloading .

In overloading which method has to execute is always take care by compiler based on refference type.

hence its also called compile time polymorphism


eg 2 - if child class redefine same method as in parent class is called method overriding

in overriding methods which method has to execute always take care by JVM based on runtime object.
hence overriding is considered as runtime polymorphism 





Comments

Popular posts from this blog

OBJECT ORIENTED CONCEPTS

Arrays programms