Finding Hidden Routes to Invalid State

A parcel batch stores a mutable list of nonnegative integer weights in grams and a cached total. Its class invariant requires the cached total to equal the sum of the list. Initially, the weights are 160 g and 90 g, and the total is 250 g. An addition method appends a weight before updating the total. The object remains usable after exceptions, and callbacks can call its public methods. Assume sequential execution. Which statements are true? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Class Invariants Questions: