Polymorphism

In Core, Java Polymorphism is one of easy concept to understand. Polymorphism definition is that Poly means many and morphos means forms.  polymorphism means ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation.

Related image

package oopsconcept;
class Overloadsample {
    public void print(String s){
        System.out.println("First Method with only String- "+ s);
    }
    public void print (int i){
        System.out.println("Second Method with only int- "+ i);
    }
    public void print (String s, int i){
        System.out.println("Third Method with both- "+ s + "--" + i);
    }
}
public class PolymDemo {
    public static void main(String[] args) {
        Overloadsample obj = new Overloadsample();
        obj.print(10);
        obj.print("Amit");
        obj.print("Hello", 100);
    }
}
 java static polymorphism image 2