rankz_VtujUdhflsoFhdgp Method Overloading in Java - All type study material

Java programming

Java programming

About Me

my self - Harvendra Singh

Search This Blog

Thursday, February 20, 2020

Method Overloading in Java


    Method Overloading in Java -

                                     
https://Erhsmathur.blogspot.com 

  • Method overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. 
  • In the last tutorial we discussed constructor overloading that allows a class to have more than one constructor having different argument list. 

Argument lists could differ in-
  1. Number of parameters.
  2. Data type of parameters.
  3. Sequence of data type of parameters.
Method overloading is known as static Polymorphism. 

Class DisplaysOverloading
{
     public void disp(char c) 
     {
         Stystem.out.println(c);
      }
      public void disp(char c,  int num)
        {
               System.out.println(c+" "+number); 
        }
   }
  Class Sample 
   {
     public static  void main (string  args[])
      {
   DisplayOverloading obj= new 
 Overloading();
          obj. disp('a'); 
     obj. dsp('a', 10);
        }
    }


5 comments: