Home Tutorial Java Scjp Part9 SCJP Module-9 Question-19

 
 

SCJP Module-9 Question-19
Posted on: July 17, 2010 at 12:00 AM
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)


Related Tags for SCJP Module-9 Question-19:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.