Which interface in Java Collections Framework does not allow duplicate elements?
Answer: B
Set interface explicitly does not allow duplicate elements. List allows duplicates, Queue is for ordered collections, and Map stores key-value pairs.
Q.254Easy
What is the underlying data structure of HashMap in Java?
Answer: B
HashMap uses a hash table with buckets (arrays of linked lists or red-black trees) to store key-value pairs for efficient O(1) average lookup time.
Q.255Easy
Which of the following maintains insertion order in Java?
Answer: C
LinkedHashSet maintains insertion order using a doubly-linked list. HashSet does not maintain order, TreeSet maintains sorted order, and ConcurrentHashMap doesn't guarantee insertion order.
Q.256Medium
What is the time complexity of get() operation in TreeMap?
Answer: B
TreeMap is based on Red-Black tree, so get(), put(), and remove() operations have O(log n) time complexity due to tree traversal.
Q.257Medium
What is the difference between ArrayList and Vector?
Answer: B
Vector is a legacy synchronized collection, while ArrayList is unsynchronized but faster. For thread-safety with ArrayList, use Collections.synchronizedList().
Q.258Medium
Which method of PriorityQueue returns the element without removing it?
Answer: C
peek() returns the head element without removing it. poll() removes and returns, remove() throws exception if empty, and pop() is not a PriorityQueue method.
Q.259Medium
What exception is thrown when you try to add a null value to a TreeSet?
Answer: A
TreeSet uses comparator or natural ordering, which cannot handle null values, throwing NullPointerException during insertion.
Q.260Medium
Which Collections utility method creates an immutable empty list?
Answer: A
Collections.emptyList() returns an immutable, empty list. Option B also works but is more verbose. Option C creates mutable list, and Option D creates mutable list from array.