Question

What is meant by the term method overloading. Give an example of method overloading to SUPPORT your answer Note: You cannot g
0 0
Add a comment Improve this question Transcribed image text
Answer #1

METHOD OVERLOADING : If a class has multiple methods with same name but differ in parameters then it is known as method overloading.

EXAMPLE :

class Adder{  

static int add(int a,int b){return a+b;}  

static int add(int a,int b,int c){return a+b+c;}  

}  

class MethodOverloading{  

public static void main(String[] args){  

System.out.println(Adder.add(1,2));  

System.out.println(Adder.add(1,2,3));  

}}

In the above example we have add function defined twice with different number of parameters, when we call the add function with 2 arguments , the add function with two parameters is called. Similarly when we call add function with three arguments, the add function defined with three parameters is called.This is function overloading.

// If you have any doubts, please feel free to ask in the comment section

// If you got the answer, please upvote, it means a lot to us :)

Add a comment
Know the answer?
Add Answer to:
What is meant by the term method overloading. Give an example of method overloading to SUPPORT...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT