Skip to content

Function overload demo

Function overload demo


Code:

class functionOverload
 {
   /*  void add(int a, int b)             // 1 – A method with two parameters
     {

        int sum = a + b;
        System.out.println(“Sum of a+b is “+sum);

     }    */

     void add(int a, int b, int c)       {

        int sum = a + b + c;
        System.out.println(“Sum of a+b+c is “+sum);

     }

     void add(double a, double b)             {

        double sum = a + b;
        System.out.println(“Sum of a+b is “+sum);
     }

     void add(String s1, String s2)

     {
       String s = s1+s2;
       System.out.println(s);
     }
}

Comment below for Query and Feedback… 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!