多项选择题
1. public class Test {
2. public
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?()
A. Object x = t.findLarger(123, “456”);
B. int x = t.findLarger(123, new Double(456));
C. int x = t.findLarger(123, new Integer(456));
D. int x = (int) t.findLarger(new Double(123), new Double(456));
相关考题
-
单项选择题
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?()
A. add this code after line 11: list = (List
) list;
B. change lines 12 and 13 to: list.add(”foo”); list.add (”bar”);
C. change the method signature on line 11 to: public void addStrings(List< extends String> list) {
D. change the method signature on line 11 to: public void addStrings(List< super String> list) {
E. No changes are necessary. This method compiles 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?()
A. 42
B. 0042
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 13.
E. Compilation fails because of an error in line 14. -
多项选择题
1. import java.util.*; 2. public class Test { 3. public static void main(String[] args) { 4. List strings = new ArrayList(); 5. // insert code here 6. } 7. } Which four, inserted at line 5, will allow compilation to succeed?()
A. String s = strings.get(0);
B. Iterator i1 = strings.iterator();
C. String[] array1 = strings.toArray();
D. Iteratori2 = strings.iterator();
E. String[] array2 = strings.toArray(new String[1]);
F. Iteratori3 = strings.iterator ();
