Can You Explain If My Answer Is Correct And Why The Others Are Not?Which Line Should Be Added Into The

Question

Can you explain if my answer is correct and why the others are not?

Which line should be added into the

removeCard method of class GroupOfCards? public class GroupOfCards { private ArrayListCard cards; // list of cards // Remove and return a card object at a specified location public Card removeCard(int index) { ________________ } // end removeCard } // end class GroupOfCards

A. cards[index] = null;

B. Card = cards.get(index); return card;

C. cards.remove(index); (correct answer)

D. return cards.remove(index);

E. Can’t decide as we don’t know the detail of class Card

My Response:The ArrayList collection class contains the object cards and it provides the remove() method. Method remove(int index) is used for removing an element of the specified index from a list.

Engineering Technology