Review Questions

graphics/rq_icon.gif

11.9

Which of these methods can be called on objects implementing the Map interface?

Select the two correct answers.

  1. contains(Object o)

  2. addAll(Collection c)

  3. remove(Object o)

  4. values()

  5. toArray()

11.10

Which statements are true about maps?

Select the two correct answers.

  1. The return type of the values() method is Set.

  2. Changes made in the set view returned by keySet() will be reflected in the original map.

  3. The Map interface extends the Collection interface.

  4. All keys in a map are unique.

  5. All Map implementations keep the keys sorted.

11.11

Which sequence of digits will the following program print?

import java.util.*;
public class Lists {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("1");
        list.add("2");
        list.add(1, "3");
        List list2 = new LinkedList(list);
        list.addAll(list2);
        list2 = list.subList(2, 5);
        list2.clear();
        System.out.println(list);
    }
}

Select the one correct answer.

  1. [1, 3, 2]

  2. [1, 3, 3, 2]

  3. [1, 3, 2, 1, 3, 2]

  4. [3, 1, 2]

  5. [3, 1, 1, 2]

  6. None of the above.

11.12

Which of these classes have a comparator() method?

Select the two correct answers.

  1. ArrayList

  2. HashMap

  3. TreeSet

  4. HashSet

  5. TreeMap

11.13

Which method prototypes are defined in the interface java.util.Map.Entry?

Select the two correct answers.

  1. Object getKey()

  2. Object setKey(Object value)

  3. void remove()

  4. Object getValue()

  5. void setValue(Object value)



     
    ASPTreeView.com
     
    Evaluation has СФЙПЛЛГХГexpired.
    Info...