- 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-
- Number of parameters.
- Data type of parameters.
- 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);
}
}
Thank you sir ji
ReplyDeletenice Sir ji
ReplyDeleteSuper ji
ReplyDeleteNotes bahut bhadiya
ReplyDeleteThanks you
ReplyDelete