Complete Question:
Suppose that you have created a program with only the following variables.
int x = 2
int y = 3
Suppose that you also have a method with the following header: public static void mathMethod(int x) Which of the following method calls are legal?
a. mathMethod(x);
b. mathMethod(y);
c. mathMethod(x, y);
d. mathMethod (x + y);
e. mathMethod(12L);
f. mathMethod (12);
g. mathMethod(12.2);
h. mathMethod (
i. mathMethod(a)
j. mathMethod(a / w
Answer:
The following options are legal
A mathMethod(x);
B mathMethod(y);
D mathMethod (x + y);
F mathMethod (12)
Explanation:
The method mathMethod(int x) Can only receive an int as argument when called.
The four options above provides an int variable to the method call. The other options do not provide an int variable.
E provides a long variable type
G provides a double variable type
H has a syntax error
I the variable a is not defined
J Both a and w are not defined