Java Reference
In-Depth Information
which of the following statements can appear on line 10 so that the Wildcard class
compiles successfully? (Select three answers.)
A. Stack<?> list = new Stack<?>();
B. List<?> list = new ArrayList<String>();
C. ArrayList<? super Date> list = new ArrayList<Date>();
D. Vector<? extends Number> list = new Vector<Integer>();
E. List<Exception> list = new LinkedList<java.io.IOException>();
17. What is the result of the following statements?
3. List<Integer> list =
Arrays.<Integer>asList(10, 4, -1, 5);
4. Collections.sort(list);
5. Integer [] array =
list.<Integer>toArray(new Integer[4]);
6. System.out.println(array[0]);
A. Compiler error on line 3
B. Line 4 throws an exception at runtime.
C. Compiler error on line 5
D. -1
E. 10
18. What is the result of the following program?
1. import java.util.*;
2.
3. public class StringSearch {
4. static class ReverseLexi implements
Comparator<String> {
5. public int compare(String a, String b) {
6. return b.compareToIgnoreCase(a);
7. }
8. }
9.
10. public static void main(String [] args) {
11. List<String> list = new ArrayList<String>();
12. list.add(“ab”);
13. list.add(“ba”);
14. list.add(“bd”);
15. list.add(“aa”);
Search WWH ::




Custom Search