7. Circle the Collection type that is best suited for each scenario. You may use
ID: 3706584 • Letter: 7
Question
7. Circle the Collection type that is best suited for each scenario. You may use a type multiple times or no times at all. One collection per question. 2 (a) You want to manage prices for a groccry store of fruits. Each fruit has an associated price. Every fruit of the same type has the same price. A. List B. Set C. Map 2(b) You want to schedule students. A student cannot be enroled for 2 instances of the same class. Your scheduler noeds to know what classes a Student is enrolled in A. List B. Set C. Map 2(c) You want to model a backpack's content. The backpack can hold multiple items and we want to distinguish items of the same type. A. List B. Set C. Map 2(d) You want to keep track of your friends finst names and their birthdays. Some of the names are repeated, but have different birthdays. You want to be able to sort your friends by their birthdays and also by their names. A. L.ist B. Set C. MapExplanation / Answer
a) answer is C part Map Reason Map can contain key value pair so Key is fruit and value is Price rest other option cannot
b)Answer is b part Set Reason set does not allow duplicate values.
c)Answer is A list because list can contain duplicate so will allow same type of item.
d)Answer is C part Map Reason again Map collection is used for holding Key value pair so first name and birthday date can be key and value for a friend.
8)
a)answer is a part.The type can not be determined
b)Answer is d , beacuse none will return boolean type
c)Answer is B part , Because a functional interface should have just one abstract method then Comparable should be functional but it does not satisfy other conditions of functional interface.
in case of any doubt and query do let me know in comments , i will be happy to help you thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.