131k views
0 votes
What type parameter must the following method be called with? int myMethod ( double[] ar ) { . . . . }

a) An empty double array.
b)A reference to an array that contains elements of type double.
c) A reference to an array that contains zero or more elements of type int.
d) An array of any length that contains double and must be named ar

1 Answer

1 vote

Final answer:

The method myMethod must be called with a reference to an array that contains elements of type double, as indicated by the method signature int myMethod (double[] ar).

Step-by-step explanation:

To determine what type parameter the method myMethod needs to be called with, let's examine the method signature: int myMethod (double[] ar). This method requires a single argument which is indicated by double[]. This means the parameter must be an array of type double.

The correct answer to the question is:

  • b) A reference to an array that contains elements of type double.

Options a), c), and d) are incorrect. An empty array is a possible argument, but the question asks for the must type, not a possible type. Option c) is incorrect because the array must contain double values, not int values. Lastly, option d) states that the array must be named 'ar' which is irrelevant because the name of the parameter in the argument does not have to match the parameter name in the method declaration.

User Simon Sot
by
7.7k points