Computer Science, asked by tanayc, 2 months ago

Write a program to overload a method add() with the following structure:
int add(int, int) - To return the sum of two integers
double add(double, double) - To return the sum of two real point values
char add(char) - To return the char when shifted by 5 places. (eg: A -> F, B -> G
..)
String add(String, String) - To return the cancatenated string of two given parameters.
Define main() to accept necessary input and call the above overloaded methods.

Answers

Answered by Anonymous
2

Answer:

Brainly is the knowledge-sharing community where 350 million students and experts put their heads together to crack their toughest.

Answered by nitinprasad212007
1

Answer:

Three ways to overload a method

In order to overload a method, the argument lists of the methods must differ in either of these:

1. Number of parameters.

For example: This is a valid case of overloading

add(int, int)

add(int, int, int)

2. Data type of parameters.

For example:

add(int, int)

add(int, float)

3. Sequence of Data type of parameters.

For example:

add(int, float)

add(float, int)

Similar questions