158k views
4 votes
ublic 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 / x);

1 Answer

5 votes

Answer:

Legal calls to the method mathMethod(int x) are

a. mathMethod(x);

b. mathMethod(y)

d. mathMethod(x + y);

f. mathMethod(12)

i. mathMethod(a);

j. mathMethod(a / x);

Step-by-step explanation:

If the variables x,y and a have been declared as ints then those method calls are legal since in the declaration of the method, mathMethod(int x) it is to accept an argument of type int when it is called. Note that in option j, the integer division a/x will still yield an int.

User Kacper Kogut
by
8.3k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.