CS FundamentalsHardProduct-company MCQ pattern

In a class diagram, Student has an association to Course with multiplicity 0..* on the Student side and 0..* on the Course side (many-to-many), modelled through an association class Enrollment carrying a grade attribute. Why is an association class needed here instead of just a plain many-to-many association?

  1. A. A many-to-many association by itself cannot carry its own attributes (like grade); an association class attaches data to the relationship itself, which conceptually becomes a linking object (one Enrollment per Student-Course pair)
  2. B. Association classes are only a stylistic choice with no functional difference from a plain association
  3. C. Multiplicities 0..* on both ends are not legal UML and must be replaced
  4. D. An association class turns the relationship into a one-to-one relationship automatically

Correct answer: A. A many-to-many association by itself cannot carry its own attributes (like grade); an association class attaches data to the relationship itself, which conceptually becomes a linking object (one Enrollment per Student-Course pair)

Plain associations (even many-to-many ones) have no place to store per-link data. An association class models exactly that: data (e.g. grade, enrollment date) that belongs to a specific pairing of a Student and a Course, not to either object alone.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic