SCJP程序员认证考试

多选题ArraryList a = new ArrayList();  a.add(“Alpha”);  a.add(“Bravo”):  a.add(“Charlie”);  a.add(“Delta”);  Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()Afor (int i=0; i< a.size(); i++) 

题目
多选题
ArraryList a = new ArrayList();  a.add(“Alpha”);  a.add(“Bravo”):  a.add(“Charlie”);  a.add(“Delta”);  Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()
A

for (int i=0; i< a.size(); i++)     System.out.println(a.get(i)));

B

for (int i=0; i< a.size(); i++)     System.out.println(a[i]);

C

while( iter.hasNext() )     System.out.println(iter.next()) ;

D

for (int i=0, i< a.size(); i++)    System.out.println(iter[i]);

E

for (int i=0; i< a.size(); i++)    System.out.println(iter.get(i));

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

The carrick bend is used to ______.

A.add strength to a weak spot in a line

B.join two hawsers

C.be a stopper to transfer a line under strain

D.join lines of different sizes


正确答案:B
carrickbend(单花大绳连结)被用于链接两个大绳。

第2题:

ArraryLista=newArrayList();a.add(Alpha”);a.add(Bravo”):a.add(Charlie”);a.add(Delta”);Iteratoriter=a.iterator();Whichtwo,addedatline17,printthenamesintheArrayListinalphabeticalorder?()

A.for(inti=0;i<a.size();i++) System.out.println(a.get(i)));

B.for(inti=0;i<a.size();i++) System.out.println(a[i]);

C.while(iter.hasNext()) System.out.println(iter.next());

D.for(inti=0,i<a.size();i++) System.out.println(iter[i]);

E.for(inti=0;i<a.size();i++) System.out.println(iter.get(i));


参考答案:A, C

第3题:

A lawyer’s income is usually very high, ________ more than one million yuan a year.

A.add up to

B.added up to

C.amounted to

D.amounting to


参考答案:D

第4题:

通常我们使用( )方法来为一个部件注册事件监听器。A.add×××ListenerB.×××ListenerSX

通常我们使用( )方法来为一个部件注册事件监听器。

A.add×××Listener

B.×××Listener

C.Listener×××

D.×××Listeneradd


正确答案:A
本题考查事件监听器的概念。每类事件都有对应的事件监听器,监听器是接口,根据动作来定义方法。AwT的构件类中提供注册和注销监听器的方法。注册监听器:publicvoidadd<ListenerType>(<Listener—Type>listener);注销监听器:publicvoidremovedListener—Type>(<ListenerType>listener)。由此可见,选项A正确。

第5题:

函数模板:template T add(T x,T y){return x+y;}下列对add函数的调用不正确的是A.add<>

函数模板:template<class T> T add(T x,T y){return x+y;} 下列对add函数的调用不正确的是

A.add<>(1,2)

B.add<int>(1,2)

C.add(1,0,2)

D.add(1.0,2.0)


正确答案:C
解析:对于templateclassT>Tadd(Tx,Ty){returnx+y;}调用时可以省略模板实参的声明,但是要求x和y的数据类型必须是一样的。

第6题:

11.public void genNumbers(){12.ArrayList numbers=new ArrayList();13.for(inti=0;i14.intvalue=i*((int)Math.random());15.IntegerintObj=newInteger(value);16.numbers.add(intObj);17.}18.System.out.println(numbers);19.}Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()

A.Line16

B.Line17

C.Line18

D.Line19

E.The object is NOT a candidate for garbage collection.


参考答案:D

第7题:

Given two files, GrizzlyBear.java and Salmon.java:If both classes are in the correct directories for their packages, and the Mammal class correctly defines the findSalmon() method, which change allows this code to compile?()

A.add import animals.mammals.*; at line 2 in Salmon.java

B.add import animals.fish.*; at line 2 in GrizzlyBear.java

C.add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java

D.add import animals.mammals.GrizzlyBear.*; at line 2 in Salmon.java


参考答案:B

第8题:

向容器添加新构件的方法是( )。

A.add()

B.insert()

C.hill()

D.set()


正确答案:A

第9题:

函数模板:templateT add(T x, T y) {return x+y;}下列对add函数的调用不正确的是A.add<

函数模板:template<class T> T add(T x, T y) {return x+y;} 下列对add函数的调用不正确的是

A.add<>(1,2)

B.add<int>(1,2)

C.add(1.0,2)

D.add(1.0,2.0)


正确答案:C
解析:对于templateclass T>
  T add (T x, T y) {return x+y;}
  调用时可以省略模板实参的声明,但是要求x和y的数据类型必须是一样的。

第10题:

下列指令中,不影响标志位的是______。

A.ADD AX,BX

B.ROL AL,1

C.JNC LEN

D.INT n


正确答案:C
解析:跳转指令是不影响标志位的,加、减运算;移位运算都会影响标志位,所以本题选C。

更多相关问题