A promise that permits several results

An operation findMatch(values, target) uses zero-based indices. Its precondition requires a nonempty integer array containing the target. Its postcondition guarantees that the array is unchanged and the returned integer rr satisfies:


0≤r<length,values[r]=target.0\leq r<\text{length}, \qquad \text{values}[r]=\text{target}.


The input array is [4, 9, 4, 7, 4] and the target is 4. Assume the call returns normally. Which statements are guaranteed by the contract? Select every guaranteed statement.

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 Design by Contract Questions: