Answered You can hire a professional tutor to get the answer.

QUESTION

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?

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.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question