5 Lecture

CS304

Midterm & Final Term Short Notes

SIMPLE ASSOCIATION

Simple association is a relationship between two classes in object-oriented programming where one class is related to the other in a non-inherited way. It allows for objects of one class to interact with objects of another class, enabling commun


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. In simple association, how many classes are involved? A) One B) Two C) Three D) Four Answer: B) Two How is simple association represented in UML diagrams? A) As a solid line B) As a dotted line C) As a dashed line D) As a double line Answer: A) As a solid line In simple association, which class is usually responsible for initiating the interaction? A) The class on the left side of the association B) The class on the right side of the association C) Both classes can initiate the interaction D) Neither class can initiate the interaction Answer: A) The class on the left side of the association Which of the following is an example of simple association? A) A car has an engine B) A car is a vehicle C) A car belongs to a person D) A car drives on a road Answer: A) A car has an engine Which of the following is true about simple association? A) It is always one-way B) It is always bidirectional C) It can be one-way or bidirectional D) It is always represented by an arrow Answer: C) It can be one-way or bidirectional What is the role of the class on the right side of the association in simple association? A) To provide functionality to the class on the left side B) To receive functionality from the class on the left side C) To initiate the interaction with the class on the left side D) To define the type of the association Answer: B) To receive functionality from the class on the left side Which of the following is not an example of simple association? A) A dog has a tail B) A book belongs to a library C) A bird can fly D) A student attends a class Answer: C) A bird can fly Which of the following is not true about simple association? A) It is a type of relationship between classes B) It enables communication and collaboration between classes C) It is always one-to-one D) It can be one-way or bidirectional Answer: C) It is always one-to-one What is the difference between simple association and inheritance? A) Inheritance involves a parent-child relationship, while simple association does not B) Simple association involves a parent-child relationship, while inheritance does not C) Simple association enables communication and collaboration between classes, while inheritance does not D) Inheritance and simple association are the same thing Answer: A) Inheritance involves a parent-child relationship, while simple association does not Which of the following is an example of bidirectional simple association? A) A person has a car B) A car belongs to a person C) A teacher teaches a class D) A student attends a class Answer: A) A person has a car and a car belongs to a person can both be examples of bidirectional simple association.


Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is simple association and how is it represented in UML diagrams? Answer: Simple association is a relationship between two classes in object-oriented programming where one class is related to the other in a non-inherited way. It is typically represented by a solid line connecting the two classes in UML diagrams. How does simple association enable communication and collaboration between classes? Answer: Simple association allows for objects of one class to interact with objects of another class, enabling communication and collaboration between the two classes. This can be achieved through methods, properties, and other interactions between the objects. What is the difference between one-way and bidirectional simple association? Answer: One-way simple association allows for objects of one class to interact with objects of another class, while the reverse is not necessarily true. Bidirectional simple association allows for objects of both classes to interact with each other. Can a class be associated with itself using simple association? Answer: Yes, a class can be associated with itself using simple association. This is known as self-association. How is the directionality of simple association determined? Answer: The directionality of simple association is determined by the roles of the two classes involved. The class on the left side of the association usually initiates the interaction, while the class on the right side receives it. What is the difference between simple association and composition? Answer: Simple association is a relationship between two classes where one class is related to the other in a non-inherited way. Composition, on the other hand, is a type of association where one class is a part of another class and cannot exist independently. Can simple association be one-to-many or many-to-many? Answer: Yes, simple association can be one-to-many or many-to-many, depending on the roles and multiplicities of the classes involved. What is the role of multiplicities in simple association? Answer: Multiplicities define the number of objects that can be associated with each other. They specify the minimum and maximum number of objects that can be associated with each class. What is the difference between simple association and aggregation? Answer: Simple association is a relationship between two classes in a non-inherited way, while aggregation is a type of association where one class is composed of one or more instances of another class. Can simple association be used in polymorphism? Answer: Yes, simple association can be used in polymorphism to enable objects of different classes to interact with each other in a non-inherited way.

In object-oriented programming, simple association is a relationship between two classes where one class is related to the other in a non-inherited way. It is typically represented by a solid line connecting the two classes in UML diagrams. Simple association enables communication and collaboration between classes by allowing objects of one class to interact with objects of another class. This can be achieved through methods, properties, and other interactions between the objects. There are two types of simple association: one-way and bidirectional. One-way simple association allows for objects of one class to interact with objects of another class, while the reverse is not necessarily true. Bidirectional simple association allows for objects of both classes to interact with each other. Simple association can also be one-to-many or many-to-many, depending on the roles and multiplicities of the classes involved. Multiplicities define the number of objects that can be associated with each other, specifying the minimum and maximum number of objects that can be associated with each class. The directionality of simple association is determined by the roles of the two classes involved. The class on the left side of the association usually initiates the interaction, while the class on the right side receives it. Simple association can be used in polymorphism to enable objects of different classes to interact with each other in a non-inherited way. It is important to note that simple association is different from composition and aggregation, as it does not imply ownership or part-whole relationships between the two classes. Overall, simple association is a fundamental concept in object-oriented programming that enables communication and collaboration between classes in a non-inherited way. By understanding how simple association works and how it can be used, developers can create more robust and flexible software systems.