Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 the maximum length of a url?

883


How to display all the prime numbers between 1 and n (n is the number, get the input from user)

926


Can we write multiple catch blocks under single try block?

1034


What is identifier in java?

1022


Whats the difference between notify() and notifyall()?

968


How can you avoid serialization in child class if the base class is implementing the serializable interface?

1021


What is a stack class in java ?

1045


How large is a boolean?

948


What is a generic type?

951


What is the use of join method?

961


What is the difference between an inner class and a sub-class?

940


what is predefined function in java?

933


What is the meaning of flag day?

959


Is java developer a good career?

962


Can a method be static?

914