Java- Polymorphism / Chapter - 9 / OOP's Concept

Java-Polymorphism

Polymorphism


One into many forms is the concept of polymorphism.


example 1: - method name is same but we can apply for different types arguments(Overloading).

public void m1(int)                  (Overloading)

public void m1(long)               (Overloading)

public void m1(float)                (Overloading)
example 2: - method signature is same but in parent class one type of implementation and in the child class another type of implementation(Overriding).

class Parent

{

public void m1()

{

System.out.println("Parent class method implemtation");

}

}

class Child extends Parent

{

public void m1()

{

System.out.println("Child class method implemtation");

}

}
example 3:- Using of parent reference to hold child object is the concept of polymorphism.

In Collection Framework List interface reference can be used to hold its child classes object like ArrayList, LinkedList, Vector, Stack.


Polymorphism

1 comment:

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com