Which statement is correct according to the diagram?

Consider the following diagram:

Which statement is correct according to the diagram?

A. responsiblePerson inherits from Person.

B. Client and Manager have nothing in common.

C. responsiblePerson can not refer to an object of class Client.

D. The object referred to as responsiblePerson can be a Manager.

Answer: D

Explanation:

In UML class diagrams, relationships between classes are represented in a number of different ways, including generalization, association, and composition.

Looking at the provided options, let’s analyze each one:

A. responsiblePerson inherits from Person C This is incorrect because the responsiblePerson is an attribute of the Task class, not a class itself, so it cannot inherit from Person.

B. Client and Manager have nothing in common C This is incorrect because both Client and Manager are specialized types of Person as indicated by the generalization arrows pointing to Person.

C. responsiblePerson can not refer to an object of class Client C This is incorrect. responsiblePerson is typed by Person, which means that it can refer to an instance of any subclass of Person, including Client.

D. The object referred to as responsiblePerson can be a Manager C This is correct. Since responsiblePerson is an attribute of the Task class with the type Person, and Manager is a subclass of Person, responsiblePerson can indeed refer to an instance of Manager.

The correct answer is based on the UML 2 Foundation specification that describes how attributes are typed by classes and can refer to instances of these classes or their subclasses (UML 2.5 specification, sections 9.3.3 and 9.5.3). The generalization relationship (represented by a triangle followed by a line) establishes a hierarchy between a more general element and a more specific element, which in this case means that Client and Manager are both specific types of Person and can be used wherever Person is expected (UML 2.5 specification, section 9.4.5).

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments