Menu
Topics Index
...
`

Replace comments with currect code to print required output


If you need explanation Read this topic

If you need Answer Take test on this topic

Replace comments with currect code to print required output
Which of the following option can be inserted in the place of comment, so that the output is 2.
import java.util.*;

public class CollectionTest {
    public static void main(String[] args) {
        NavigableSet<Integer> check = new TreeSet<Integer>();
        check.add(2);check.add(5);check.add(9);
        System.out.println(/* CODE HERE */);
    }
}

A. check.tailSet(3)
B. check.headSet(5)
C. check.pollLast()
D. check.lower(8)
Topic: Java TreeSet - TreeSet Examples in Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

B is the corrct answer as it returns the elment less than the passed element

Posted by Harish Reddy Bitla    2013-08-21 04:09:11


B headset takes values which strictly returns value that is less than the one sent as argument

Posted by Karteek Paruchuri    2013-08-21 04:09:53


ans is b b'cuz its correct one

Posted by Aditya Nani    2013-08-21 04:27:59


Congratulations Harish Reddy. You are this dose winner. Please send us your mobile details in a private message and we will process the recharge asap.

Posted by Merit Campus    2013-08-22 09:15:45


© meritcampus 2019

All Rights Reserved.

Open In App