网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
scala语言中,关于List的定义。不正确的是?()
- A、vallist=List(1,2,3)
- B、vallist=List[Int](1,2,3)
- C、vallist=List[String](‘a’,’b’,’c’)
- D、vallist=List[String]()
参考答案
更多 “scala语言中,关于List的定义。不正确的是?()A、vallist=List(1,2,3)B、vallist=List[Int](1,2,3)C、vallist=List[String](‘a’,’b’,’c’)D、vallist=List[String]()” 相关考题
考题
现有: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();)
考题
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();)
考题
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.
考题
在scala中定义一个List,以下语法正确的是()A、vallist=List(4,7,3)B、vallist=List[Int](1,2,3)C、vallist=List[String](‘a’,’b’,’c’)D、vallist=List[Int]("a","b")
考题
以下使用scala语言,定义一个List,其中语法不正确的是?()A、vallist=List(1,2,3)B、vallist=List[Int](1,2,3)C、vallist=List[String](‘a’,’b’,’c’)D、vallist=List[String]()
考题
在scala中对于列表操作以下对于这些列表操作正确的是vart=List(1,2,3)vart2=t.+:("test")()A、返回结果为List("test",1,2,3)B、返回结果为List(1,2,3,"test")C、不同类型的元素不能进行列表相加D、以上说法都不对
考题
现有: 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.
考题
在scala中对于以下2个列表的操作,那些说法说法正确vart=List(1,2,3)vart2=List(4,5)()A、vart3=t++t2得到List(1,2,3,4,5)B、vart3=List.concat(t,t2)得到List(1,2,3,4,5)C、vart3=t:::t2得到List(1,2,3,4,5)D、vart3=t.:::(t2)得到List(1,2,3,4,5)
考题
通过如下程序块可以知道,在list中的构造中,可以通过::进行列表的构造valsite:List[String]=List("Runoob","Google","Baidu")valsite1:List[String]="Runoob":("Google")::("Baidu"::Nil);
考题
以下对于这些列表操作正确的是vart=List(1,2,3)vart2=t.:+("test")()A、返回结果为List("test",1,2,3)B、返回结果为List(1,2,3,"test")C、不同类型的元素不能进行列表相加D、以上说法都不对
考题
以下关于List的定义。正确的是?()A、vallist=List(4,7,3)B、vallist=List[Int](1,2,3)C、vallist=List[String](‘a’,’b’,’c’)D、vallist=List[Int]("a","b")
考题
对于以下2个列表的操作,那些说法说法不正确vart=List(1,2,3)vart2=List(4,5)()A、vart3=t++t2得到List(1,2,3,4,5)B、vart3=List.concat(t,t2)得到List(1,2,3,4,5)C、vart3=t:::t2得到List(1,2,3,4,5)D、vart3=t.:::(t2)得到List(1,2,3,4,5)
考题
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. 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 (); )
考题
单选题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.
考题
单选题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.
考题
单选题list=[1,2,3],list[-1]的值为()A
1B
3C
2D
[]
热门标签
最新试卷