click below
click below
Normal Size Small Size show me how
SCJA-drills-chap06
Question | Answer |
---|---|
What are composition and association? | Composition and association are both general descriptions for object-to-object relationships. |
What happens when a relationship is created, object-oriented-wise? | A relationship is created when an object contains a reference to another object, often through an instance variable. |
Give four properties of a direct association. | Direct association is a “has-a” relationship, is a weak relationship, has no life cycle responsibilities and tends to be the default relationship if no other relationshipseems to fit. |
What happens to objects that have a direct association if the relationship is lost? | Two objects that have a direct association will logically make sense if the relationship is lost. |
Give four properties of composition association. | Composition association is a “composed-of” relationship, is a strong association, has life cycle responsibilities and represents possession and ownership. |
What happens to objects that have a composition association if the relationship is lost? | Two objects that have a composition association will not logically make sense if the association is lost. |
What is the inner/container relationship between objects related by a composition association? | When two objects have a composition association, the containing object often requires the inner object. |
Give three properties of an aggregation association. | Aggregation association is a “part-of” relationship, is a weak relationship and has no life cycle responsibilities. |
What happens to objects that have a aggregation association if the relationship is lost? | Two objects that have an aggregation association will logically make sense if the relationship is lost. |
Give three properties of a temporary association. | Temporary association is also known as a dependency, is a weak relationship and has no life cycle responsibilities. |
When is a temporary association relationship created? | A temporary association relationship is created when a return value, method parameter, or local variable is used. |
When is a one-to-one relationship possible? | One-to-one relationships are possible with both composition and association. |
What is particular to one-to-one relationships, in regard to references? | One-to-one relationships have one object that contains a reference to another object. |
When are one-to-many relationships possible? | One-to-many relationships are possible with both composition and association. |
What is particular to one-to-many relationships, in regard to references? | One-to-many relationships are one object that contains a reference to an array or collection of similar objects. |
When are many-to-many relationships possible? | Many-to-many relationships are possible only with association. |
What is particular to many-to-many relationships, in regard to references? | Many-to-many relationships have many similar objects that contain a reference to the same array or collection of objects. |
Define asssociation navigation. | Association navigation is a term used to describe the ability to access an object that is contained in another object. |
How may relationships be navigated? | Relationships may be able to navigate bidirectional or unidirectional. |
Which role are getter methods playing in regard to navigation? | Getter methods are often used to navigate an inner object. |
Give a characteristic of association, specific to object creation/passed? | In an association, the inner object normally is not created in the containing object but is instead passed to it as a method argument. |
Give a characteristic of compostion, specific to object creation/passed? | In a composition, the inner object is normally created in the containing object. |
Give a characteristic of one-to-many relationships, specific to storage of objects? | In a one-to-many relationship, the inner object is stored in an array or collection. |
Give two special characteristic of many-to-many relationships, in regard to references. | A many-to-many relationship is when objects in an array or collection each contain a reference to another array or collection. Can only exist for associations. |