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?
- 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)
- B. Association classes are only a stylistic choice with no functional difference from a plain association
- C. Multiplicities 0..* on both ends are not legal UML and must be replaced
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- An activity diagram shows a fork bar splitting one flow into two concurrent activities (ValidateAddress and ChargeCard), which later…
- A class diagram shows Shape as an abstract class with an italicized name and an italicized method + area(): double, and Circle, Square as…
- In a sequence diagram, a long thin rectangle drawn on top of a lifeline is called an activation bar (execution occurrence). What does its…
- A class diagram shows Employee with attribute - salary: double and operation + getSalary(): double. What do the leading - and + symbols…
- A sequence diagram shows a loop combined fragment labelled loop [for each item in cart] wrapping a single message validateItem(item) sent…
- A class diagram shows Vehicle as a superclass with a generalization (hollow triangle arrow) pointing from Car and Truck up to Vehicle. If…