计算机二级

下列语句能给数组赋值,而不使用for循环的是A.myArray{[1]="One";[2]="Two";[3]="Three";}B.String s[5]=new String[] {"Zero","One","Two","Three","Four"};C.String s[]=new String[] {"Zero","One","Two","Three","Four"};D.String s[]=new String[]= {"Zero","One","Two","Three","Four"};

题目

下列语句能给数组赋值,而不使用for循环的是

A.myArray{[1]="One";[2]="Two";[3]="Three";}

B.String s[5]=new String[] {"Zero","One","Two","Three","Four"};

C.String s[]=new String[] {"Zero","One","Two","Three","Four"};

D.String s[]=new String[]= {"Zero","One","Two","Three","Four"};

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

第1题:

以下对枚举类型名的定义中正确的语句是

A.enum a={one,two,three};

B.enum a {a1,a2,a3} ;

C.enum a={'1','2','3'} ;

D.enum a {"one","two","three"} ;


enum a{a1, a2 , a3} ;

第2题:

以下对枚举类型的定义,正确的是()。

A.enum a={one,two,three};

B.enum a{a1,a2,a3};

C.enum a{'1', '2', '3'};

D.enum a{ "one","two","three" };


B

第3题:

4、下列选项中,不能创建字典对象的语句是()。

A.{'one':1, 'two':2, 'three':3}

B.dict('one':1, 'two':2, 'three':3)

C.dict([('one',1), ('two',2), ('three',3)])

D.dict(zip(['one','two','three'], [1,2,3]))


dict('one':1, 'two':2, 'three':3)

第4题:

1、以下对枚举类型名的定义中正确的是()。

A.enum a={one,two,three};

B.enum a {one=9,two=-1,three};

C.enum a={"one","two","three"};

D.enum a {"one","two","three"};


enum a {one=9,two=-1,three};

第5题:

以下对枚举的定义,正确的是

A.enum a={one.two,three}

B.enum a{a1,a2,a3};

C.enum a={'1','2','3'};

D.enum a {"one","two","three"}


B

第6题:

下列给字符串二维数组进行赋值的语句中,错误的是()。

A.String s[ ] [ ] = new String [ ] [ ] { { “One “ , “ Two “ }, { “ Three “ , “ Four “ } } ;

B.String s[ ] [ ] = { { “ One “ , “Two “},{ “ Three “ , “ Four “ } } ;

C.String s[ ] [ ] = new String [ ] [ ] { { “Zero”} , { “ One ” , “Two” , “ Three” , “ Four” } } ;

D.String s[ 2] [2 ] = { { “ One ” , “Two”},{“ Three” , “ Four” } } ;


String s[ 2] [2 ] = { { “ One ” , “Two”},{“ Three” , “ Four” } } ;

第7题:

下列选项中,不能创建字典对象的语句是()。

A.{'one':1, 'two':2, 'three':3}

B.dict('one':1, 'two':2, 'three':3)

C.dict([('one',1), ('two',2), ('three',3)])

D.dict(zip(['one','two','three'], [1,2,3]))


dict('one':1, 'two':2, 'three':3)

第8题:

下列语句能给数组赋值而不使用for循环的是

A.myArray{[1]="One";[2]="Two";[3]="Three";}

B.String s[5]=new String[]{"Zero", "One", "Two", "There", "Four"};

C.String s[]=new String[]{"Zero", "One", "Two", "There", "Four"};

D.String s[]=new String[]=|"Zero", "One", "Two", "There", "Four"};


正确答案:C
解析:A)、D)语法不正确,B)中s[5]的形式只能通过for循环的格式进行赋值,而不能直接赋值。C)中表达式左侧的“[]”说明现在定义一个数组,不需要指明数组长度,而表达式右侧“[]”在后面直接紧跟初始内容时也是不需要指定数组大小的,数组大小直接由初值长度决定。

第9题:

以下对枚举类型名的定义中正确的是______。

A.enum a={one,two,three};

B.enum a{one=9,two=-1,three};

C.enum a={"one","two","three"};

D.enum a{"one","two","three"};


正确答案:B
解析:声明枚举类型用enum开头。例如:enum weekday(sun,mon,tue,wed,thu,fri,sat); 说明:1、在C编译中,对枚举元素按常量处理,同时可以改变他们的值。2、枚举值可以用来做判断比较。3、一个整数不能直接赋给一个枚举变量。