CMS专题

单选题Given:  int[] myArray=newint[] {1, 2,3,4, 5};  What allows you to create a list from this array?()AList myList = myArray.asList();BList myList = Arrays.asList(myArray);CList myList = new ArrayList(myArray);DList myList = Collections.fromArray(myArray);

题目
单选题
Given:  int[] myArray=newint[] {1, 2,3,4, 5};  What allows you to create a list from this array?()
A

 List myList = myArray.asList();

B

 List myList = Arrays.asList(myArray);

C

 List myList = new ArrayList(myArray);

D

 List myList = Collections.fromArray(myArray);

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

第1题:

为将数组myArray的长度由6改为10,现采取以下编码:int[]myArray=newint[6];myArray=newint[10];(覆盖)代码执行后,以下叙述哪项是正确的?()

A.数组myArray的长度已由6改为10,其中前6个元素的值不变,后四个元素的值为空。

B.数组myArray的长度已由6改为10,其中前6个元素的值不变,后四个元素需再经过初始化后才能使用。

C.数组myArray的长度已由6改为10,原来6个元素的值全部丢失。

D.数组myArray的长度没有变化。


参考答案:C

第2题:

Given:int[]myArray=newint[]{1,2,3,4,5};Whatallowsyoutocreatealistfromthisarray?()

A.ListmyList=myArray.asList();

B.ListmyList=Arrays.asList(myArray);

C.ListmyList=newArrayList(myArray);

D.ListmyList=Collections.fromArray(myArray);


参考答案:B

第3题:

下列的数组定义语句,不正确的是()

A、inta[]=newint[5]{1,2,3,4,5}

B、int[,]a=newinta[3][4]

C、int[][]a=newint[][4];

D、int[]a={1,2,3,4};


参考答案:AC

第4题:

下面是几条动态初始化二维数组的语句,指出其中正确的:

A、intarr5[][]=newint[4,5];

B、int[][]arr6=newint[4,5];

C、intarr7[,]=newint[4,5];

D、int[,]arr8=newint[4,5];


正确答案:D

第5题:

Given:Which code, inserted at line 15, allows the class Sprite to compile?()

A.Foo { public int bar() { return 1; }

B.new Foo { public int bar() { return 1; }

C.new Foo() { public int bar() { return 1; }

D.new class Foo { public int bar() { return 1; }


参考答案:C

第6题:

以下程序执行的结果是什么?()int[]myArray=newint[3];try{for(inti=0;i<=myArray.length;i++){myArray[i]=i*3;System.out.println("myArray数组的第"+i+"个元素的值是:"+myArray[i]);}}catch(ArrayIndexOurOfBoubsExceptione){System.out.println("数组下标越界");}

A.程序执行,屏幕上显示“数组下标越界”

B.程序出现异常,屏幕上提示出现数组下标越界异常

C.程序正常执行结束,屏幕上显示数组中每个元素的值

D.程序编译出错


参考答案:A

第7题:

下列数组的初始化正确的是_________。

A.int[]score=newint[5]{1,2,3,4,5};

B.int[5]score=newint[]{1,2,3,4,5};

C.intscore={1,2,3,4,5};

D.int[]score=newint[5];


正确答案:D

第8题:

在C#中,()正确定义了一个具有10个int类型的数组。

A、intiArray=newint[10];

B、int[]iArray=newint;

C、int[]iArray=newint(10);

D、int[]iArray=newint[10];


参考答案:D

第9题:

Given:11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+"");15.}Whatistheresult?()

A.Compilationfailsbecauseofanerrorinline13.

B.AClassCastExceptionisthrownatruntime.

C.123

D.Compilationfailsbecauseofanerrorinline14.

E.Compilationfailsbecauseofanerrorinline12.


参考答案:C

第10题:

int[][] myarray3=new int[3][]{new int[3]{5,6,2},new int[5]{6,9,7,8,3},new

int[2]{3,2}};myarray3[2][2]的值是( )。


正确答案:
 

更多相关问题