What is method Overloading in the perspective of OOPS?

Answer Posted / amarnath88888

Two or more methods having same name but different
signatures in the same class or in super class, sub
class(inheritance) then, that method is said to be
overloaded method.
This process is known as method overloading.

Note: Signature of a method means
1) no. of parameters
2) type of the parameter
3) order of the parameters

And a method cant be said as overloaded method only with the
change of the return type alone.

For example,
1) //for no of parameters

void display(int a,int b,int c)
{
System.out.println("This is 3 arguments method");
}

void display(int a,int b)
{
System.out.println("This is 2 arguments method");
}

2) //for type of parameters

void display(int a,int b)
{
System.out.println("This is 2 int arguments method");
}

void display(float a,float b)
{
System.out.println("This is 2 float arguments method");
}

3) //for order of parameters

void display(int a,float b)
{
System.out.println("This is int,float argument method");
}

void display(float a,int b)
{
System.out.println("This is float,int argument method");
}

Note: // cant determine only with return type

void display(int a,int b)
{
System.out.println("This is 2 arguments method without
return type");
}

int display(int a,int b)// compile error here
{
System.out.println("This is 2 arguments method with return
type");
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is immutable in java?

538


What does it mean that a class or member is final?

555


What is flush () in java?

554


Do I need java on my pc?

508


What is variable length arguments in java?

512






State the merge-sort principle and its time complexity.

571


What is unicode full form?

548


what do you mean by stream pipelining in java 8? Explain

531


How do you sort arrays in java?

521


How can you traverse a linked list in java?

678


Why does java have two ways to create child threads?

464


What is a method vs function?

552


What is the difference between && and & in java?

567


What is hashset in java?

524


What are the different types of multitasking?

652