Question 207 / 297:  What is the result of compiling and running the following code?
import java.util.SortedSet;

import java.util.TreeSet;

public class Test {

public static void main(String[] args) {

TreeSet<Integer> map = new TreeSet<Integer>();

map.add(1);

map.add(2);

map.add(4);

map.add(7);

SortedSet<Integer> smap = map.subSet(2,7);

map.add(5);

map.add(9);

System.out.println(smap);

}

}

A  [2, 4, 5, 7]
B  [2, 4, 7]
C  [2, 4, 5, 7, 9]
D  [2, 4, 5]
E  [2, 4]
<< First < Previous Next > Last >>
Explanation:

subSet: returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.

Exam Home Page
Ask
Jugnu Khan
Start Quiz
Marion Cabalfin
Start Quiz
Yasser Ibrahim
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>