Limited access

Upgrade to access all content for this subject

Consider the following code segment that merges two arrays into an ArrayList.

 public ArrayList<Integer> mergeThem(int[] first, int[] second)
 {
  ArrayList<Integer> mergeList = new ArrayList<Integer>();
  for (int i = 0; i < first.length; i++)
  mergeList.add(i, first[i]);
  for (int j = 0; j < second.length; j++)
  mergeList.add(first.length + j, **INSERT CODE**);

  return mergeList;
 }

Which of the following can be used to replace INSERT CODE so that the merge will work as intended?

I. second[i]
II. second[j]
III. second[first.length - second.length]

A

I only.

B

II only.

C

III only.

D

I and II only.

E

II and III only.

Select an assignment template