Method overloading

Method overloading is a process of writing multiple method with the same name by changing the parameters.
when we are overloading the methods we need to check the following rules:

  • Methods name must be same.
  • Return type can be any type .
  • Parameters must be changed in term of number or type or order.                                                               Example:                                                                                                                                                             
    Class Hello {
                    void sum(byte a, byte b){
    System.out.println(a+b);
    }
    Void sume(int a, int b){
    System.out.println(a+b);
    }
    }
                                                             

0 comments :

Post a Comment