Collections

6.How does PriorityQueue order its elements by default?
  • A. FIFO (First In, First Out)
  • B. LIFO (Last In, First Out)
  • C. Natural Ordering (Comparable)
  • D. Random Order

Natural Ordering (Comparable)

Natural Ordering (Comparable)

7.Which of the following is NOT a part of the Java Collections Framework?
  • A. HashMap
  • B. Hashtable
  • C. Vector
  • D. ConcurrentHashMap

ConcurrentHashMap

ConcurrentHashMap

8.What happens when remove() is called on a PriorityQueue?
  • A. Removes the highest-priority element
  • B. Removes the last inserted element
  • C. Removes a random element
  • D. Throws an exception if the queue is empty

Removes the highest-priority element

Removes the highest-priority element

9.Which class is best suited for implementing a thread-safe list?
  • A. ArrayList
  • B. LinkedList
  • C. CopyOnWriteArrayList
  • D. HashSet

CopyOnWriteArrayList

CopyOnWriteArrayList

10.How does LinkedHashSet maintain element order?
  • A. Based on hashCode()
  • B. In insertion order
  • C. In sorted order
  • D. Randomly

In insertion order

In insertion order