Assume the declaration of the method xMethod is as follows. This means that xMet
ID: 3823590 • Letter: A
Question
Assume the declaration of the method xMethod is as follows. This means that xMethod is sent one object that is an array of double values.
public static void xMethod(double [ ] a);
Which of the following could be used to call xMethod?
a. xMethod(5.7);
b. xMethod(“this one is correct”);
c. double [ ] z = {8.4, 9.3, 10.7};
xMethod( z[2] );
d. double [ ] z;
z = new double[6];
xMethod( z );
aExplanation / Answer
public static void xMethod(double [ ] a);
Which of the following could be used to call xMethod?
a. xMethod(5.7);
b. xMethod(“this one is correct”);
c. double [ ] z = {8.4, 9.3, 10.7};
xMethod( z[2] );
d. double [ ] z;
z = new double[6];
xMethod( z );
The correct option is d.
double [ ] z;
z = new double[6];
xMethod( z );
Because in option a. instead of object a value is passed in the method. And same is the case with option b. and c. a value is passed in method.
But in option d. the object of a double array is being passed which is same as mentioned in the method declaration.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.