Test: Computer Science

For the following question, consider the following code:

public static void main(String[] args)

{

  double[] vec = {4,8,10,18};

  System.out.println(fun(vec));

privatestaticdouble fun(double[] x)

{

  double p = 0;

  for(int i = x.length-1; i > -1; i--)

  {

    p += x[i];

  }

  return p / x.length;

}

1.

Which of the following is a possible output for this program?

1/6 questions

0%
Learning Tools by Varsity Tutors