For each method call in the table below, determine which of the methods on the t
ID: 3588939 • Letter: F
Question
For each method call in the table below, determine which of the methods on the top table is actually called, or indicate that it is impossible because there is either no method that matches, there are several methods that match, or something else is wrong.
Method
Identifier
Method Signature
a
int addition (int x, int y)
b
double addition(int x, int y)
c
double addition(int x, double y)
d
double addition (double x, int y)
e
double addition(double x, double y)
f
double addition (double x, double y, double z)
Method
Identifier
or Impossible
Method Call
double sum = addition(0.4, 0.2);
int sum = addition (1, 5);
double sum = addition (3, 5.1);
addition (5.1, 3);
double sum = addition (1, 2, 3);
int sum = addition(2.1, 3.2, 4.3);
double sum = addition (5, 1);
double sum = addition (1.2, 2.3, 3.4, 4.5);
Method
Identifier
Method Signature
a
int addition (int x, int y)
b
double addition(int x, int y)
c
double addition(int x, double y)
d
double addition (double x, int y)
e
double addition(double x, double y)
f
double addition (double x, double y, double z)
Explanation / Answer
1. double sum = addition(0.4,0.2) - e (Since arguments and return types are of double type)
2. int sum = addition(1,5) - a (Since arguments and return types are of type int)
3. double sum = addition(3,5.1) - c (Since arguments are int and double type, return type is double)
4. addition(5.1,3) - d (Arguments are double and int)
5. double sum = addition(1,2,3) - impossible, no method matches the signature
6. int sum = addition(2.1,3.2,4.3) - impossible, since the existing method has return type double
7. double sum = addition(5,1) - b (Arguments are of int type and return type is of double data type)
8. double sum = addition(1.2,2.3,3.4,,4.5) - impossible, no method matches the given signature
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.