Question 1
Which of the following is correct to perform the set intersection of two sets s1 and s2?
◦ s1.join(s2)
◦ s1.intersection(s2)
◦ s1.intersect(s2)
◦ s1.retainAll(s2)
Question 2
Analyze the following code.
import java.util.*;
public class Test {
public static void main(String[] args) throws Exception {
| Set set = new TreeSet(); |
| System.out.println(set.first()); |
}
}
◦ The program displays Blue
◦ The program may display Red, Blue, or Green.
◦ The program displays Red
◦ The program displays Green
◦ The program cannot compile, because the first() method is not defined in Set.