Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 );

a

Explanation / 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.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote