Home / Java Programming / Objects and Collections :: Discussion

Discussion :: Objects and Collections

  1. Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

  2. A.
    java.util.ArrayList
    B.
    java.util.LinkedHashMap
    C.
    java.util.HashMap
    D.
    java.util.TreeMap

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    LinkedHashMap is the collection class used for caching purposes. FIFO is another way to indicate caching behavior. To retrieve LinkedHashMap elements in cached order, use the values() method and iterate over the resultant collection.


Be The First To Comment