Java Reference
In-Depth Information
11. numbers.add(309L);
12. Iterator iter = numbers.iterator();
13. while(iter.hasNext()) {
14. System.out.print(iter.next());
15. }
Which of the following statements are true? (Select two.)
A.
The code compiles successfully.
B.
The output is 8675null309.
C.
The output is indeterminate.
D.
Line 6 generates a compiler error.
E.
Line 12 generates a compiler error.
10.
What is the result of the following statements?
7. TreeSet<String> tree = new TreeSet<String>();
8. tree.add(“one”);
9. tree.add(“One”);
10. tree.add(“ONE”);
11. System.out.println(tree.ceiling(“On”));
A.
one
B.
One
C.
ONE
D.
On
11.
Given the following declaration:
Map<String, Double> map = new HashMap<String, Double>();
which of the following statements are valid?
A.
map.add(“pi“, 3.14159);
B.
map.add(“e“, 2.71828D);
C.
map.add(“log(1)“, new Double(0.0));
D.
map.add('x', new Double(123.4));
E.
None of the above.
12.
What is the result of the following program?
import java.util.*;
public class MyComparator implements Comparator<String> {
public int compare(String a, String b) {
Search WWH ::
Custom Search