Java Reference
In-Depth Information
16. ReverseLexi comparator = new ReverseLexi();
17. Collections.sort(list, comparator);
18. int index = Collections.binarySearch(list,
“ab”, comparator);
19. System.out.println(index);
20. }
21. }
A. 1
B. 2
C. 3
D. 4
E. The code does not compile.
19. What is the result of the following statements?
6. String [] names = {“Tom”, “Dick”, “Harry”};
7. List<String> list = names.asList();
8. list.set(0, “Sue”);
9. System.out.println(names[0]);
A. Sue
B. Tom
C. Compiler error on line 7
D. Compiler error on line 8
E. Line 9 causes an exception at runtime.
20. What is the result of the following code?
4. List<String> names = Arrays.asList(“Tom”, “Dick”,
“Harry”, “Sue”);
5. Collections.sort(names);
6. int x = Collections.binarySearch(names, “Tom”);
7. System.out.println(x);
A. 0
B. 1
C. 2
D. 3
E. -1
Search WWH ::




Custom Search