black

SCJP程序员认证考试

登录

单项选择题

public class Drink implements Comparable { 
public String name; 
public int compareTo(Object o) { 
return 0; 
} 
} 
and: 
Drink one = new Drink(); 
Drink two = new Drink(); 
one.name= “Coffee”; 
two.name= “Tea”; 
TreeSet set = new TreeSet(); 
set.add(one); 
set.add(two); 
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?() 

A. Tea
B. Coffee
C. Coffee Tea
D. Compilation fails.
E. The code runs with no output.
F. An exception is thrown at runtime.

相关考题

多项选择题 1. public class Test {  2. public  T findLarger(T x, T y) {  3. if(x.compareTo(y) > 0) {  4. return x;  5. } else {  6. return y;  7. }  8. }  9. }  and:  22. Test t = new Test();  23. // insert code here  Which two will compile without errors when inserted at line 23?()

单项选择题 11. public void addStrings(List list) {  12. list.add(”foo”);  13. list.add(”bar”);  14. }  What must you change in this method to compile without warnings?()

单项选择题 11. public static void append(List list) { list.add(”0042”); }  12. public static void main(String[] args) {  13. List intList = new ArrayList();  14. append(intList);  15. System.out.println(intList.get(0));  16. }  What is the result?()

All Rights Reserved 版权所有©求知题库网库(csqiuzhi.com)

备案号:湘ICP备14005140号-1

经营许可证号:湘B2-20140064