Computer Science, asked by vibek1203, 1 year ago

Which class is an ordered collection that may contain duplicates?

Answers

Answered by syedtalha777
0
Question: At the beginning of this lesson, you learned that the core collection interfaces are organized into two distinct inheritance trees. One interface in particular is not considered to be a true Collection, and therefore sits at the top of its own tree. What is the name of this interface? 
Answer: Map

Question: Each interface in the collections framework is declared with the <E> syntax, which tells you that it is generic. When you declare a Collection instance, what is the advantage of specifying the type of objects that it will contain? 
Answer: Specifying the type allows the compiler to verify (at compile time) that the type of object you put into the collection is correct, thus reducing errors at runtime. 

Question: What interface represents a collection that does not allow duplicate elements? 
Answer: Set 

Question: What interface forms the root of the collections hierarchy? 
Answer: Collection 

Question: What interface represents an ordered collection that may contain duplicate elements? 
Answer: List 

Question: What interface represents a collection that holds elements prior to processing? 
Answer: Queue 

Question: What interface repesents a type that maps keys to values? 
Answer: Map 

Question: What interface represents a double-ended queue? 
Answer: Deque 

Question: Name three different ways to iterate over the elements of a List. 
Answer: You can iterate over a List using streams, the enhanced for statement, or iterators. 

Question: True or False: Aggregate operations are mutative operations that modify the underlying collection. 
Answer: False. Aggregate operations do not mutate the underlying collection. In fact, you must be careful to never mutate a collection while invoking its aggregate operations. Doing so could lead to concurrency problems should the stream be changed to a parallel stream at some point in the future. 

Similar questions