A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Example of PolyMorphism: Method Overloading

Method Overloading

What is the polymorphism as Method Overloading in Java?

Deep Concept about Method Overloading Example of Method Overloading in Java:-





class Bank1
{
    String getCustomerName(String s)
    {
        return s;
    }  
}

class sbi1 extends Bank1
{
    String getCustomerName(String fn, String ln)
    {
        return fn+ln;
    }
}

class icici1 extends Bank1
{
    String getCustomerName(String fn, String mn, String ln)
    {
        return fn+mn+ln;
    }
}

class polymorphism2
{
    public static void main(String args[])
    {
        Bank1 b= new Bank1();
        sbi1 s =new sbi1();
  
        icici1 i =new icici1();
        System.out.println(b.getCustomerName("Heera"));

        //System.out.println(b.getCustomerName("Heera"));
         System.out.println(s.getCustomerName("Heera", "Babu"));
         System.out.println(i.getCustomerName("Babu", "Heera", "Singh"));
    }
}


 

LEARN TUTORIALS

.

.