Free Version
Difficult

# Array Algorithm Description

APCSA-L6PKVG

Consider the following method.

// Precondition: nums will contain at least one element
public static int[ ] methodA(int[] nums, int n)
{
int m = nums.length / 2;
int[] temp = new int[nums.length+1];

for (int i=0; i<m; i++)
{
temp[i] = nums[i];
}

for (int i=temp.length-1; i>=m; i--)
{
temp[i] = nums[i-1];
}

temp[m] = n;
return temp;
}


Which of the following would be a correct statement to describe this method?

A

The method returns a new array that is an exact copy of the nums array.

B

The method returns a new array that is a copy of all the elements from the nums array with one additional element inserted at the end that contains the value 0.

C

The method returns a new array that is a copy of all the elements from the nums array with one additional element inserted at the end that contains the value of n.

D

The method returns a new array that is a copy of all the elements from the nums array with an additional integer n inserted at the midpoint of the returned array.

E

The method returns a new array that is a copy of the nums array except the last element of nums is not copied to the returned array.