11.4 |
Which statements are true about collections? Select the two correct answers.
|
11.5 |
What will be the result of attempting to compile and run the following program? import java.util.*; public class Sets { public static void main(String[] args) { HashSet set1 = new HashSet(); addRange(set1, 1); ArrayList list1 = new ArrayList(); addRange(list1, 2); TreeSet set2 = new TreeSet(); addRange(set2, 3); LinkedList list2 = new LinkedList(); addRange(list2, 5); set1.removeAll(list1); list1.addAll(set2); list2.addAll(list1); set1.removeAll(list2); System.out.println(set1); } static void addRange(Collection col, int step) { for (int i = step*2; i<=25; i+=step) col.add(new Integer(i)); } } Select the one correct answer.
|
11.6 |
Which of these methods are defined in the Collection interface? Select the three correct answers.
|
11.7 |
What will be the output from the following program? import java.util.*; public class Iterate { public static void main(String[] args) { List l = new ArrayList(); l.add("A"); l.add("B"); l.add("C"); l.add("D"); l.add("E"); ListIterator i = l.listIterator(); i.next(); i.next(); i.next(); i.next(); i.remove(); i.previous(); i.previous(); i.remove(); System.out.println(l); }; }; Select the one correct answer.
|
11.8 |
Which of these methods from the Collection interface will return the value true if the collection was modified during the operation? Select the two correct answers.
|