Composition Context and Generalization - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
Composition context
Please select the best answer.
A.
May be used anywhere that aggregation is used
B.
May be used only for composition
C.
May be used only to show context references
D.
Must be used for composition
The correct answer is B.
The composition context may be used only for composition. A is incorrect because the composition context may not be used with aggregation. Context references are a benefit of the context diagram but are not its only purpose, so C is incorrect. Composition may be diagrammed using the solid diamond notation, not just the composition context, so D is incorrect.
2.
Generalization
Please select the best answer.
A.
Defines classes that together form the definition for a single object
B.
Is a high-level view of the class diagram
C.
Uses all the association notation
D.
Connects classes that exist for a common purpose
The correct answer is A.
Generalization defines classes that together form the definition for a single object. It is not a high-level view of the class diagram as is the structured analysis context diagram, so B is incorrect. C is incorrect because generalization uses only the association line, not multiplicity, roles, or constraints. D is incorrect because generalization links classes that describe the same object, not a common purpose.
3.
The discriminator
Please select the best answer.
A.
Is the name placed on the generalization name
B.
Is an optional model element
C.
Defines the differences between the subclasses in a generalization
D.
Is a type of constraint used only with generalization associations
The correct answer is C.
The discriminator defines the differences between the subclasses in a generalization. A is incorrect because the discriminator is placed between the superclass and all its subclasses, not on any one association line. B is incorrect because although many people forget to document the discriminator, it is in fact required. Discriminators and constraints are two distinct model elements, so D is also incorrect.
4.
Multiplicity
Please select the best answer.
A.
Is required for all types of associations
B.
Is not used with generalization
C.
Is used only on the subclass end of the generalization association
D.
Is optional with generalization
The correct answer is B.
Multiplicity is not used with generalization, so it is not required for all associations. A is incorrect because generalization is a unique type of association. Multiplicity is not used at all with generalization, so C and D are incorrect.
5.
The composition context diagram
Please select the best answer.
A.
Shows the position of a composition within a system context
B.
Is an alternative diagram for aggregation
C.
May be used only for composition
D.
May be used only if supported by the tool
The correct answer is C.
The composition context diagram may be used only for composition. B is incorrect because the diagram makes the assumption that the composite multiplicity is always one and that there is a life span dependency. A is incorrect because the composition context shows only the context of the composite itself. Whether or not a tool supports the UML does not dictate the definition of the model element. It only makes using the UML more or less difficult, so D is also incorrect.