Consider the following class diagram:
Which statement is true about the class diagram?
A. The preferred age to open a bank account is 18 years old or older
B. Only customers who are 18 years old or older can open a bank account.
C. The age condition should only hold when the setAge(Integer) function is called
D. An object of Customer with age set to 18 or greater will raise an exception.
Answer: B
Explanation:
In UML 2, a class diagram is used to depict the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among the classes. The constraint {age >= 18} in the Person class diagram indicates a condition that must hold true for the instances of the Person class whenever they are used in the context of a BankAccount. This constraint is an invariant of the Person class that specifies the rule for the attribute age.
Now, let’s consider the provided options and explain why option B is correct:
A. The preferred age to open a bank account is 18 years old or older C This statement is incorrect because the diagram does not indicate a preference; it indicates a constraint or a rule.
B. Only customers who are 18 years old or older can open a bank account C This is the correct statement. The {age >= 18} constraint next to the age attribute of the Person class signifies that any instance of Person associated with a BankAccount must be at least 18 years old. Since Person is connected to BankAccount with the role name customer, this implies that only persons who are at
least 18 can be customers of a bank account.
C. The age condition should only hold when the setAge(Integer) function is called C This statement is incorrect because the constraint {age >= 18} is not a condition that applies only when the setAge operation is invoked. Instead, it is a class invariant that must always hold true for any instance of Person.
D. An object of Customer with age set to 18 or greater will raise an exception C This is incorrect because the UML diagram specifies a constraint, not an exception condition. The constraint ensures validity, not the raising of an exception.
The answer is verified according to the UML 2 Foundation documents, such as the UML 2.5 specification, where class diagrams and constraints are defined. The specification states that constraints are semantic conditions or restrictions expressed in natural language text or in a machine-readable language that must hold true for the system being modeled (UML 2.5 specification, section 7.9).
Latest OMG-OCUP2-FOUND100 Dumps Valid Version with 270 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund