SCJP Module-9 Question-30

The Sample program will test your understanding about the NavigableSet Interface of Collection framework.

 
 

Share on Google+Share on Google+

SCJP Module-9 Question-30

Ads

The Sample program will test your understanding about the NavigableSet Interface of Collection framework.

Given below the sample code :

1  import java.util.ArrayList;
2  import java.util.List;
3  import java.util.NavigableSet;
4  import java.util.TreeSet;
5  public class Check {
6  public static void main(String... args) {
7  List<Integer> l = new ArrayList<Integer>();
8  lst.add(12);
9  lst.add(6);
10 lst.add(2);
11 lst.add(3);
12 lst.add(30);
13 lst.add(21);
14 NavigableSet<Integer> nset = newTreeSet(l);
15  // Place code here
16  }

What code line should be at line 15 to the print smallest element  grater than 12 in the given array list ?

1. System.out.println( nset.higher(12));

2. System.out.println( nset.lower(12));

3.System.out.println(nset.headSet(12));

4.No need to add any line.

Answer

(1)

Advertisements

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