| | | | MCQ Tutorial - JAVA->Collection | | | | 1.) You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?
| | Options are: | | A.) java.util.List
| | B.) java.util.Set
| | C.) java.util.Collection
| | D.) java.util.Map
| | Correct Option: B | | | | | | | 2.) Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
| | Options are: | | A.) java.util.ArrayList
| | B.) java.util.LinkedHashSet
| | C.) java.util.HashSet
| | D.) java.util.List
| | Correct Option: A | | | | | | | 3.) Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
| | Options are: | | A.) java.lang.StringBuffer
| | B.) java.lang.Double
| | C.) java.lang.String
| | D.) java.lang.Character
| | Correct Option: A | | | | | | | 4.) Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?
| | Options are: | | A.) The answer depends on the implementation of the existing instance
| | B.) HashMap
| | C.) TreeMap
| | D.) LinkedHashMap
| | Correct Option: D | | | | | | | 5.) Which interface does java.util.Hashtable implement? | | Options are: | | A.) Java.util.Collection
| | B.) Java.util.Map
| | C.) Java.util.List
| | D.) Java.util.HashTable
| | Correct Option: B | | | | | | | | | | | |