多选题
Use the following code example for the next four
questions: public class Client { Address
address; AccountNum[] accountNums; void
setAddress(Address newAddress) { address =
newAddress; } public Client() {
accountNums = new AccountNum[2]; accountNums[0] = new
AccountNum(); accountNums[1] = new AccountNum();
} }
多选题
In the preceding code segment, what is the relationship of the Client
object and the address variable?
A. Direct association
B. Temporary association
C. Composition association
D. Aggregation association
【正确答案】
A
【答案解析】 直接关联是最佳答案,因为从逻辑上来说,一个Client对象有一个(“has an”)Address对象。B、C和D不正确。
多选题
In the preceding code segment, what is the relationship of the Client
object and the accountNums variable?
A. Direct association
B. Temporary association
C. Composition association
D. Aggregation association
【正确答案】
C
【答案解析】 这是一个组合关联,因为Client对象由AccountNum对象“组成”。这是一种强关系,因为Client对象维护AccountNumber对象的生命周期。A、B和D不正确。
多选题
In the preceding code segment, what is the multiplicity between the
Client object and the address variable?
A. One-to-one
B. One-to-many
C. Many-to-many
【正确答案】
A
【答案解析】 因为没有数组或者集合涉及Client对象或者Address对象中的一个,这必须是一对一关系。B和C不正确。B不正确,因为address变量是单个变量,因此不满足多个。C不正确,因为Client对象和address变量两者都不能认为是多个,因为它们都只有一个。
多选题
In the preceding code segment, what is the multiplicity between the
Client object and the accountNums variable?
A. One-to-one
B. One-to-many
C. Many-to-many
【正确答案】
B
【答案解析】 AccountNumber对象数组应该是一对多的产物。A和C不正确。A不正确,因为accountNums变量是一个数组,因此必须是多个。C不正确,因为只有一个Client对象。
多选题
Which of the following statements are true? (Choose all that apply.)
A. Association navigation can be quad-directional.
B. Association navigation can be bidirectional.
C. Association navigation can have no direction.
D. Association navigation can be unidirectional.
【正确答案】
B、D
【答案解析】 关系只能是单向的或者双向的。A和C不正确。A不正确,因为不存在4个方向的关系。B不正确,因为不可能有一种关系没有方向。
提交答案
关闭