Q: In which of the following relationship objects of related classes can occur independently?
Solution: In both Aggregations and Association of objects of related classes can occur independently. For example, an employee can have a bank and a bank can have an employee. Also, Association is a superset of Aggregation, therefore, it also follows the same.
Q: In which of the following relationship objects of related classes are strongly dependent?
Solution: In both Composition and Association, objects of related classes are strongly dependent. For example, books will be destroyed if the library does not exist (talking about objects of classes).
Q: Composition is a __________ type of Association relationship.
Solution: Composition is a strong type of Association relationship because in this case, objects are strongly dependent on each other. For example, human and heart cannot exist without each other.
Q: Aggregation is a __________ type of Association relationship.
Solution: Aggregation is a weak type of Association relationship because in this case objects of related classes can occur independently. For example, bank and employee can occur independently.
Q: Which type of relationship is modelled by Association?
Solution: Association models the has-a relationship between classes. Similar to aggregation, in this children can exist without a parent, therefore, they have a relationship.
Q: Which container is used to store elements as key-value pair?
Solution: C++ provides these three containers(map, multimap and unordered map) to store elements as key-value pair.
Q: Which container can have the same keys?
Solution: C++ provide multimap container that is used to make map that can contain same keys i.e. {a: 5} and {a:10} both can exist.
Q: Which container is best to keep the collection of distinct elements?
Solution: C++ provides a set container to store a collection of distinct elements. This container behaves similar to mathematical sets.
Q: Which container is used to keep priority based elements?
Solution: C++ provides priority queue container that stores elements based on their priority. For example, if the absolute value is the priority then -6 will be kept before 4 in the priority queue.
Q: Sets are implemented using _______________________
Solution: Sets are implemented using the search tree so that we can check the presence of any element to be inserted in O(logn) time in order to remove conflicts between elements.
You Have Score    | /10 |