Solved

You Have Created a Fruit Class and a ShoppingCart Class

Question 38

Multiple Choice

You have created a Fruit class and a ShoppingCart class. Which of the following methods will correctly add a Fruit object to an array list named fruits in the ShoppingCart class?


A) public void add(Fruit aFruit)
{
Fruits.add(new Fruit(aFruit) ) ;
}
B) public void add(Fruit aFruit)
{
Fruits.add(aFruit) ;
}
C) public void add(Fruit aFruit)
{
Fruits.addItem(new Fruit(aFruit) ) ;
}
D) public void add(Fruit aFruit)
{
Fruits.addItem(aFruit) ;
}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions