Monday, September 19, 2011

Quiz of the day | OCPJP (14)

1. import java.util.*;
2. public class BCA {
3. public static void main(String[] args) {
4. List desk = new ArrayList();
5. desk.add("b"); desk.add("c"); desk.add("a");
6. Collection.sort(desk);
7. System.out.print(desk.indexOf("b"));
8. Collection.reverse(desk);
9. System.out.print(" " + desk.indexOf("c"));
10. System.out.println(" " + desk.indexOf("a"));
11. } }

What is the result?

A. 1 2 0
B. 2 2 1
C. 2 0 2
D. 1 0 2
E. Compilation fails.
F. An exception is thrown at runtime.


DOWNLOAD the answer

0 comments: