Problem of the Day
Friday, February 13, 2026
Problem:
A program needs data structures to model the following eating utensils that will be used on a camping trip:
ForkKnifeSpoonSpork (a combination of a spoon and a fork)FoldingKnifeKitchenKnife
Which data structure(s) would be appropriate for managing these classes?
- create a separate variable for each utensil, and manage them in a Runner class
- create a
Utensilsuperclass and an Array or ArrayList ofUtensilobjects - create a
Utensilsuperclass for the objects, as well as aKnifesuperclass for the knives, and an Array or ArrayList ofUtensilobjects
- I only
- I and II only
- I and III only
- II and III only
The correct answer is d. The utensils listed can all be managed in an Array or ArrayList, but those structures must be declared with a single class, so choice I won't work for us. Choice II could work, although Choice III makes sense as well: we have a variety of different types of knives, so it may be useful to write a Knife superclass to help in categorizing those utensils as well.