ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Composition
|
|
Association
|
|
Aggregation
|
|
Polymorphic
|
Detailed explanation-1: -This kind of relationship is termed as association.. Aggregation and Composition are subsets of association meaning they are specific cases of association. In both aggregation and composition object of one class “owns” object of another class. But there is a subtle difference.
Detailed explanation-2: -Composition: Composition is a “part-of” relationship. Simply composition means mean use of instance variables that are references to other objects. In composition relationship both entities are interdependent of each other for example “engine is part of car”, “heart is part of body”.
Detailed explanation-3: -Association is a relationship that is established between two distinct classes through their objects. Associations can take the following forms: many-to-1, many-to-many, 1-to-1, 1-to-many. An object of one class communicates with objects of other classes to utilize its functionality and services.
Detailed explanation-4: -Explanation: Association relationship between classes is made using the objects of classes like we have a bank object denoting ABC bank and some objects of Employee class XYZ1, XYZ2 and so on. So, in this case, XYZ1 is an employee in ABC bank so there is a relationship between these two objects.
Detailed explanation-5: -A composition association relationship represents a whole–part relationship and is a form of aggregation. A composition association relationship specifies that the lifetime of the part classifier is dependent on the lifetime of the whole classifier.