Engineering Homework Help

Can you explain if my answer is correct and why the others are not?Which line should be added into the

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

Get Your Custom Essay Written From Scratch
We have worked on a similar problem. If you need help click order now button and submit your assignment instructions.
Just from $13/Page
Order Now

Which line should be added into the

removeCard method of class GroupOfCards? public class GroupOfCards { private ArrayList 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.