150k views
5 votes
Suppose you have the following function prototype and variable declaration: public void goop(int[ ] z) int[ ] x = new int[10]; Which is the correct way to call the goop method with x as the argument:

(A) goop(x);
(B) goop(x[ ]);
(C) goop(x[10]);
(D) goop(&x);
(E) goop(&x[ ]);

User Malgaur
by
5.1k points

1 Answer

7 votes

Answer:

A) goop(x);

Step-by-step explanation:

A method in Java is a collection of statements that perform some specific task and return the result to the caller. A method can perform some specific task without returning anything. Methods allow us to reuse the code without retyping the code.

In the defined method below:

public void goop(int[ ] z)

int[ ] x = new int[10];

the correct way to call the goop method will be to put the argument x in the parenthesis.

User Marcjae
by
5.4k points