网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator(); } public static void main(String[] args) { List list = new ArrayList(); list.add(” 1”); list.add(”2”); list.add(”3”); for (Object obj: reverse(list)) System.out.print(obj + “,”); } What is the result?()
A
3,2,1,
B
1,2,3,
C
Compilation fails.
D
The code runs with no output.
E
An exception is thrown at runtime.
参考答案
参考解析
解析:
暂无解析
更多 “单选题public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator(); } public static void main(String[] args) { List list = new ArrayList(); list.add(” 1”); list.add(”2”); list.add(”3”); for (Object obj: reverse(list)) System.out.print(obj + “,”); } What is the result?()A 3,2,1,B 1,2,3,C Compilation fails.D The code runs with no output.E An exception is thrown at runtime.” 相关考题
考题
现有:3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.publicstaticvoidmain(String[]args){7.8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);}}哪一行插入到第9行将导致输出abc”?()A.for(Objecto:list)B.for(Iteratoro:list)C.for(Objecto:list.iterator())D.for(Iteratoro:list.iterator();o.hasNext();)
考题
-list是一个合法的集合引用-getCollection()返回一个合法集合的引用哪两个是合法的()
A.for(Objecto;list)B.for(Objecto:list.iterator())C.for(Objecto:getCollection())D.for(Iteratori=list.iterator();i.hasNext();)
考题
3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.7.publicstaticvoidmain(String[]args){8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);11.}12.}哪一行插入到第9行将导致输出abc”?()A.for(Objecto:list)B.for(Iteratoro:list)C.for(Objecto:list.iterator())D.for(Iteratoro:list.iterator();o.hasNext();)
考题
Listlist=//morecodehere12.Collections.sort(list,newMyComparator());Whichcodewillsortthislistintheoppositeorderofthesortinline12?()
A.Collections.reverseSort(list,newMyComparator());B.Collections.sort(list,newMyComparator());list.reverse();C.Collections.sort(list,newInverseComparator(newMyComparator()));D.Collections.sort(list,Collections.reverseOrder(newMyComparator()));
考题
publicstaticIteratorreverse(Listlist){Collections.reverse(list);returnlist.iterator();}publicstaticvoidmain(String[]args){Listlist=newArrayList();list.add(”1”);list.add(”2”);list.add(”3”);for(Objectobj:reverse(list))System.out.print(obj+,”);}Whatistheresult?()A.3,2,1,B.1,2,3,C.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.
考题
现有: 3.import java.util.*; 4.class ForInTest { 5.static List list = new ArrayList(); 6.public static void main (String [] args){ 7. 8.list.add("a"); list.add("b"); list.add("c"); 9.//insert code here 10.System.out.print(o); } } 哪一行插入到第9行将导致输出“abc”?() A、 for(Object o : list)B、 for(Iterator o : list)C、 for(Object o : list.iterator())D、 for(Iterator o : list.iterator(); o.hasNext (); )
考题
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.
考题
public class Alpha{ private static Character() ids; public static void main( String[] args){ ids = new Character[args.length]; for (int i=0; iids[i] = new Character( args[i] ); System.out.print( ids[i] ); } } } What is correct?() A、 Compilation fails.B、 The code runs with no output.C、 An exception is thrown at runtime.D、 The code runs, outputing a concatenated list of the arguments passed to the program.
考题
11. List list = // more code here 12. Collections.sort(list, new MyComparator()); Which code will sort this list in the opposite order of the sort in line 12?() A、 Collections.reverseSort(list, new MyComparator());B、 Collections.sort(list, new MyComparator()); list.reverse();C、 Collections.sort(list, new InverseComparator( new MyComparator()));D、 Collections.sort(list, Collections.reverseOrder( new MyComparator()));
考题
public static void search(List list) { list.clear(); list.add(”b”); list.add(”a”); list.add(”c”); System.out.println(Collections.binarySearch(list, “a”)); } What is the result of calling search with a valid List implementation?()A、0B、1C、aD、bE、cF、The result is undefined.
考题
现有: - list是一个合法的集合引用 - getCollection()返回一个合法集合的引用 哪两个是合法的?() A、 for(Object o ; list)B、 for(Object o : getCollection()C、 for(Object o : list.iterator()D、 for(lterator i ; list.iterator() ; i.hasNext () )E、 for(lterator i=list.iterator(); i.hasNext (); )
考题
- list 是一个合法的集合引用 - getCollection() 返回一个合法集合的引用 哪两个是合法的()A、for(Object o ; list)B、for(Object o : list.iterator())C、for(Object o : getCollection())D、for(Iterator i = list.iterator(); i.hasNext (); )
考题
1. import java.util.*; 2. class ForInTest { 3. static List list = new ArrayList(); 4. 5. static List getList() { return list; } 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. // insert code here 10. System.out.print(o); 11. } 12. } 第 9 行插入哪一项将输出 abc?() A、for(char o: list)B、for(Object o: getList())C、for(Object o: getList();)D、for(Object o: o.getList())
考题
public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator(); } public static void main(String[] args) { List list = new ArrayList(); list.add(” 1”); list.add(”2”); list.add(”3”); for (Object obj: reverse(list)) System.out.print(obj + “,”); } What is the result?() A、 3,2,1,B、 1,2,3,C、 Compilation fails.D、 The code runs with no output.E、 An exception is thrown at runtime.
考题
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、 Iterator i2 = strings.iterator();E、 String[] array2 = strings.toArray(new String[1]);F、 Iterator i3 = strings.iterator();
考题
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、 42B、 0042C、 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.
考题
多选题现有: - list是一个合法的集合引用 - getCollection()返回一个合法集合的引用 哪两个是合法的?()Afor(Object o ; list)Bfor(Object o : getCollection()Cfor(Object o : list.iterator()Dfor(lterator i ; list.iterator() ; i.hasNext () )Efor(lterator i=list.iterator(); i.hasNext (); )
考题
单选题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
42B
0042C
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.
考题
单选题public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator(); } public static void main(String[] args) { List list = new ArrayList(); list.add(” 1”); list.add(”2”); list.add(”3”); for (Object obj: reverse(list)) System.out.print(obj + “,”); } What is the result?()A
3,2,1,B
1,2,3,C
Compilation fails.D
The code runs with no output.E
An exception is thrown at runtime.
考题
多选题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?()AString s = strings.get(0);BIterator i1 = strings.iterator();CString[] array1 = strings.toArray();DIterator i2 = strings.iterator();EString[] array2 = strings.toArray(new String[1]);FIterator i3 = strings.iterator();
考题
单选题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. List list = // more code here 12. Collections.sort(list, new MyComparator()); Which code will sort this list in the opposite order of the sort in line 12?()A
Collections.reverseSort(list, new MyComparator());B
Collections.sort(list, new MyComparator()); list.reverse();C
Collections.sort(list, new InverseComparator( new MyComparator()));D
Collections.sort(list, Collections.reverseOrder( new MyComparator()));
考题
单选题现有: 3. import java.util.*; 4. class ForInTest { 5. static List list = new ArrayList(); 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print(o); 11. } 12. } 哪一行插入到第9行将导致输出“abc”?()A
for(Object o : list)B
for(Iterator o : list)C
for(Object o : list.iterator())D
for(Iterator o : list.iterator(); o.hasNext (); )
考题
单选题现有: 3.import java.util.*; 4.class ForInTest { 5.static List list = new ArrayList(); 6.public static void main (String [] args){ 7. 8.list.add("a"); list.add("b"); list.add("c"); 9.//insert code here 10.System.out.print(o); } } 哪一行插入到第9行将导致输出“abc”?()A
for(Object o : list)B
for(Iterator o : list)C
for(Object o : list.iterator())D
for(Iterator o : list.iterator(); o.hasNext (); )
考题
单选题1. import java.util.*; 2. class ForInTest { 3. static List list = new ArrayList(); 4. 5. static List getList() { return list; } 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. // insert code here 10. System.out.print(o); 11. } 12. } 第 9 行插入哪一项将输出 abc?()A
for(char o: list)B
for(Object o: getList())C
for(Object o: getList();)D
for(Object o: o.getList())
考题
单选题public class Alpha{ private static Character() ids; public static void main( String[] args){ ids = new Character[args.length]; for (int i=0; iids[i] = new Character( args[i] ); System.out.print( ids[i] ); } } } What is correct?()A
Compilation fails.B
The code runs with no output.C
An exception is thrown at runtime.D
The code runs, outputing a concatenated list of the arguments passed to the program.
考题
多选题- list 是一个合法的集合引用 - getCollection() 返回一个合法集合的引用 哪两个是合法的()Afor(Object o ; list)Bfor(Object o : list.iterator())Cfor(Object o : getCollection())Dfor(Iterator i = list.iterator(); i.hasNext (); )
热门标签
最新试卷