Learn AP Comp Sci

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:

Which data structure(s) would be appropriate for managing these classes?

  1. create a separate variable for each utensil, and manage them in a Runner class
  2. create a Utensil superclass and an Array or ArrayList of Utensil objects
  3. create a Utensil superclass for the objects, as well as a Knife superclass for the knives, and an Array or ArrayList of Utensil objects
  1. I only
  2. I and II only
  3. I and III only
  4. II and III only

Show solution:

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.