Step 1: Understanding relationships in UML class diagrams.
In Unified Modeling Language (UML), class diagrams are used to visually represent the structure of a system. These diagrams show classes, attributes, methods, and relationships between classes.
Several types of relationships exist in UML diagrams such as association, aggregation, inheritance, and composition. Each relationship has its own graphical symbol.
Step 2: Meaning of composition.
Composition represents a strong "whole–part" relationship between two classes. In this relationship, the contained object cannot exist independently of the parent object. If the parent object is destroyed, the contained objects are also destroyed.
For example, a House class may contain Room objects. If the house is destroyed, the rooms cannot exist independently.
Step 3: Representation of composition in UML.
Composition is represented in UML diagrams using a filled (solid) diamond symbol. The filled diamond is placed near the class that represents the whole object.
Step 4: Evaluating the options.
(A) Empty diamond symbol: Incorrect. This represents aggregation, which is a weaker relationship.
(B) Filled diamond symbol: Correct. It represents composition.
(C) Empty triangle symbol: Incorrect. This is used for inheritance.
(D) Filled triangle symbol: Incorrect. Not used for composition in UML diagrams.
Step 5: Conclusion.
Therefore, composition in a UML class diagram is represented by a filled diamond symbol.
Final Answer: Filled diamond symbol