|
|
Authorized user can see question and answers. Please log in or sign up. 
|
#85. Given: 1. import java.util.*; 2. public class TestSet { 3. enum Example { ONE, TWO, THREE } 4. public static void main (String[] args ) { 6. coll.add(Example.THREE); 7. coll.add(Example.THREE); 8. coll.add(Exampie.THREE); 9. coll.add(Example.TWO); 10. coll.add(Example.TWO): 11. coll.add(Example.ONE); 13. } 14. }
Which statement is true about the set variable on line 12?
Show comments for this question (0)
Add comments
Link to this question
|
|
#86. Given: 11 . //insert code here 12. private N min, max; 13. public N getMin() { return mm; } 14. public N getMax() { return max; } 15. public void add(N added) { 16. if (min == null added.doubleValue() < min.doubleValue()) 17. min = added; 18. if (max == null II added.doubleValue() > max.doubleValue()) 19. max= added; 20. } 21. }
Which two, inserted at line 1 1, will allow the code to compile? (Choose two.)
Show comments for this question (0)
Add comments
Link to this question
|
|
#87. Given: 3. public int compareTo (Object o ) { 4. return 0; 5. } 6. }
and: 20. Drink one = new Drink(); 21. Drink two = new Drink(); 22. one.name= “Coffee”; 23. two .name= “Tea”; 24. set.add(one); 25. set.add(two);
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?
Show comments for this question (0)
Add comments
Link to this question
|
|
#88. Given a pre-generics implementation of a method: 11. public static int sum (List list ) { 12. int sum = 0; 13. for ( Iterator iter = list. iterator(); iter. hasNext(); ) { 14. int i = ((lnteger)iter.next()).intValue(); 15. sum +=I; 16. } 17. return sum; 18. }
Which three changes must be made to the method sum to use generics? (Choose three.)
Show comments for this question (0)
Add comments
Link to this question
|
|
|
|
gen. 0.298
|
Server date 06:07 10-01-2009
|
Developed by Zip © 2006
|
|
 |
|
|