SCJP Module-9 Question-19

The sample program given below will test your understanding about the List and Collection interface of Collection framework.

 
 

Share on Google+Share on Google+

SCJP Module-9 Question-19

Ads

The sample program given below will test your understanding about the List and Collection interface of Collection framework.

Given below the sample code :

import java.util.*;
public class z {
public static void Find(List<String> list) {
list.clear();
list.add("ba");
list.add("aa");
list.add("ca");
list.add("ca");
System.out.println(Collections.binarySearch(list, "ca"));
System.out.println(list);
}
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
Find(list);
}}


What will be the output of the above code ?

1. Undefined : no output

2. 2

3. [ ba, aa , ca, ca ]

4. 2  [ba, aa , ca, ca]

Answer

(4)


Advertisements

Posted on: July 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles