Test association constraints

A warehouse diagram gives each Batch between one and four associated Item objects. Its Java constructor receives an array and is intended to enforce three rules: the array length is from one to four inclusive, every entry is non-null, and no object reference appears twice.


The labels A, B, C, D, and E denote distinct non-null item objects. Each row is an independent constructor call using the listed entries in a new array. All three rules must hold. Enter the exact word accept or reject for each call.

Candidate array entriesConstructor result
Empty array
A, B
A, A
A, null
A, B, C, D
A, B, C, D, E

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 Implementing Class Diagrams in Java Questions: