Java Reference
In-Depth Information
return a.toLowerCase().compareTo(b.toLowerCase());
}
public static void main(String [] args) {
String [] values = {“abc”, “Abb”, “aab”};
Arrays.sort(values, new MyComparator());
for(String s : values) {
System.out.print(s + “ “);
}
}
}
A. aab Abb abc
B. Abb aab abc
C. abc Abb aab
D. aab abc Abb
E. The code does not compile.
13. What is the result of the following statements?
3. Map<Integer, Integer> map = new HashMap<Integer, Integer>(10);
4. for(int i = 1; i <= 10; i++) {
5. map.put(i, i * i);
6. }
7. System.out.println(map.get(4));
A. Compiler error on line 3
B. Compiler error on line 5
C. Compiler error on line 7
D. 16
E. 25
14. What is the result of the following statements?
10. int [] random = {6, -4, 12, 0, -10};
11. int x = 12;
12. int y = Arrays.binarySearch(random, x);
13. System.out.println(y);
A. 2
B. 4
C. The result is undefined.
D. Line 12 throws an exception at runtime.
E. Compiler error on line 12
Search WWH ::




Custom Search