以下哪种初始化数组的方式是错误的?()  A、String[] name =,“zhang”,”wang”,”li”-B、String*3+ names=,“zhang”,”wang”,”li”-C、String names[] =new String[3]  names*0+=”wang”D、names*1+=”wang”E、names*2+=”li”F、以上皆正确

题目

以下哪种初始化数组的方式是错误的?()  

  • A、String[] name =,“zhang”,”wang”,”li”-
  • B、String*3+ names=,“zhang”,”wang”,”li”-
  • C、String names[] =new String[3]  names*0+=”wang”
  • D、names*1+=”wang”
  • E、names*2+=”li”
  • F、以上皆正确
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

以下电子邮箱地址的格式中,正确的是( )。

A.wang.163.com

B.wang@163.com

C.wang#163.com

D.www.wang.163.com


正确答案:B
解析:电子邮件地址的格式为:用户名主机域名。主机域名采用层次结构,每层构成一个子域名,子域名之间用圆点分隔,自左至右依次为:计算机名、机构名、网络名、最高域名。

第2题:

定义结构体数组:

struct stu

{ int num;

char name[20];

}x[5]={1,"LI",2,"ZHAO",3,"WANG",4,"ZHANG",5,"LIU"};

for(i=1;i<5;i++)

printf("%d%c",x[i].num,x[i].name[2];

以上程序段的输出结果为( )。

A.2A3N4A5U

B.112A3H41

C.1A2N3A4U

D.2H3A4H51


正确答案:A
解析:本题主要考查结构体数组的使用。x[i].num为结构体x[i]中的num成员,x[i].name[2]是结构体x[i]中name成员的第3个元素。程序执行循环过程时:第1次循环,i=1,输出x[1].num,x[1].name[2]的值,即2A;第2次循环,i=2,输出x[2].num,x[2].name[2]的值,即 3N;第3次循环,i=3,输出x[3].num,x[3].name[2]的值,即4A;第4次循环,i=4,输出x[4].num,x[4].name[2]的值,即5U。

第3题:

D

Anne and Joseph are talking about an interesting question. Why do some people change their names? There can be many reasons. Hanna changed her name to Anne because she thought it would be easier for people to remember. On the other hand, Joseph is thinking about changing his name to an unusual name because he wants to be different.

People have a lot of reasons for changing their names. Film stars, singers, sportsmen and some other famous people often change their names because they want names that are not ordinary, or that have special sound. They chose the “new name” for themselves instead of the name their parents gave them when they were born.

Some people have another reason for changing their names. They have moved to a new country and want to use a name that is usual there. For example, Li Kaiming changed his name to Ken Lee when he moved to the United States. He uses the name Ken at his job and at school. But with his family and Chinese friends, he uses Li Kaiming. For some people, using different names makes life easier in their new country.

In many countries, a woman changes her family name to her husband’s after she gets married. But today, many women are keeping their own family name and not using their husband’s. Sometimes , women use their own name in some situations (情况)and their husband’s in other situations . And some use both their own name and their husband’s.

根据短文内容,完成下面表格。

different people

reason to change the name

Hanna

It is ____61____ for people to remember.

Joseph

He wants to have a name that’s ____62_____.

famous people

Their name may sound _____63_____.

Li Kaiming

Using different names can make ____64_____ easier.

a woman

After she gets _____65_____, she may change her name.

61._________________________________________________________________________


正确答案:
easier

第4题:

定义结构体数组: struct stu { int num; char name[20]; }x[5]={1,"LI",2,"ZHAO",3"WANG",4,"ZHANG",5"LIU"}; for(i=1;i<5;i++) printf("%d %c", x[i].num, x[i].name[2]); 以上程序段的输出结果为( ).

A.2A3N4A5U

B.1I2a3h4I

C.1A2N3A4U

D.2H3A4H5I


正确答案:A
解析:本题主要考查结构体数组的使用。x[i].mum为结构体x[i]中的num成员,x[i].name[2]是结构体x[i]中name成员的第3个元素。程序执行循环过程时:第1次循环,i=1,输出x[1].num,x[1].name[2]的值,即2A:第2次循环,i=2,输出x[2].mum,x[2].name[2]的值,即3N;第3次循环,i=3,输出x[3].num,x[3].name[2]的值,即4A;第4次循环,i=4,输出x[4].num,x[4].name[2]的值,即5U。

第5题:

importjava.util.*;

publicclassNameList{

privateListnames=newArrayList();

publicsynchronizedvoidadd(Stringname){names.add(name);}

publicsynchronizedvoidprintAll(){

for(inti=0;iSystem.out.print(names.get(i)+);

}

}

publicstaticvoidmain(String[]args){

finalNameListsl=newNameList();

for(inti=0;i<2;i++){

newThread(){

publicvoidruin(){

sl.add(”A”);

sl.add(”B”);

sl.add(”C”);

sl.printAll();

}

}.start();

}

}

}

Whichtwostatementsaretrueifthisclassiscompiledandrun?()


参考答案:E, F

第6题:

定义结构体数组:

struct stu

{int num;

charname[20];

}x[5]={1,"LI",2,"ZHAO",3,"WANG",4,"ZHANG",5,"LIU"};

for(i=1;i<5;i++)

printf("%d%C",x[i].num,x[i]name[2]);

以上程序段的输出结果为( )。

A.2A3N4A5U

B.112A3H41

C.1A2N3A4U

D.2H3A4H51


正确答案:A
解析:本题主要考查结构体数组的使用。x[i].num为结构体x[i]中的num成员,x[i].name[2]是结构体 x[i]中name成员的第3个元素。程序执行循环过程时:第1次循环,i=1,输出x[1].num,x[1].name[2]的值,即2A:第2次循环,i=2,输出x[2].num,x[2].name[2]的值,即3N;第3次循环,i=3,输出x[3].num,x[3].name[2]的值,即4A:第4次循环,i=4,输出x[4].num,x[4].name[2]的值,即5U。

第7题:

It's very interesting to study names of different countries.Chinese names are different (1) foreign names.Once an English lady came to visit me.When I was introduced to her she said, “ Glad to meet you, Miss Ping.” Then she gave me her name card with three words on it:"Betty J.Black.So I said, “Thank you, Miss Betty.” We looked at each other and laughed heartily.Later I found that the English people (2)their family names last and the given names first, while their middle names are not used very much.I explained to her that the Chinese family name comes first, the given name last, so she(3) never call me Miss Ping.She asked if we Chinese had a middle name.I told her we didn't.but people may often find three words

on a Chinese name card.In this case the family name still come first, and the other words after it(4)a two-word given name.it is quite usual in China.My sister is Li Xiaofang.She has two words in her given name instead (5) just one like mine.(完型填空)

A.Put

B.From

C.Should

D.of

E.are


答案:B A C E D 

解析:本段意思:研究不同国家的名称是非常有趣的。中国人的名字不同于外国人的名字。有一次,一位英国女士来看我。当我被介绍给她时,她说:“很高兴认识你,萍小姐。然后她给了我她的名片,上面有三个字:“贝蒂·j·布莱克。”所以我说:“谢谢你,贝蒂小姐。我们面面相觑,开怀大笑。后来我发现英国人把姓放在最后,名放在前面,中间的名字用得不多。我向她解释中国姓在前,名在后,所以她永远不要叫我萍小姐。她问我们中国人有没有中间名。我告诉她我们没有。但是人们经常会在一张中文名片上发现三个字。在这种情况下,姓仍然在前面,在它后面的其他单词是两个单词组成的名字。这在中国很常见。我妹妹是李小芳。她有两个字在她的名字,而不像我一样只有一个。


第8题:

阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。

[说明]

本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。

[Java代码]

import java. io. *:

public class User {

public String user;

public Siring pass;

public User() { }

public User( String u,String p) {

user=u;

pass=p;

}

public String (1) () { return this. user; }

public String (2) () { return this. pass; }

public static void main(String[] args) {

User ua[]={new User("Li","123456"), new User("wang","654321"),

new User("Song","666666")};

while(true) {

InputStreamReader reader = new InputStreamReader(System. in);

BufferedReader inpul = new BnfferedReader(reader);

System. out. print("Enter your name:");

String name = null;

try { name = input. readLine();}

catch (IOException ex) {}

if((3)) break;

int i;

for (i=0;i<3;i++) {

if (name. equals(ua[i]. getUser())){

System. out. println("密码:"+ua[i].getPass());

(4);

}

}

if ((5)) System. out. println("该用户不存在!");

}

}

}


正确答案:(1) getUser (2) getPass (3) name.equals("end") (4) break (5) i= =3或i>=3或i>2或其他等效形式
(1) getUser (2) getPass (3) name.equals("end") (4) break (5) i= =3或i>=3或i>2或其他等效形式 解析:User类中包括数据成员User和pass,分别存储用户名和口令,另有一个构造函数和getUser()、getPass()两个成员函数,分别用于获取用户名和口令。main ()中包含一个User类型的数组ua.当用户输入一个用户名后,在ua中查找,若找得到则输出对应的口令,否则输出相应的提示信息。
(1)~(2)从后面的代码中可以推断出,User类中有getUser()、getPass()两个成员函数;
(3)此处给出了退出程序的判断条件,即输入的用户名等于“end”;
(4)此处的for循环用于查找用户名,若找到了可即刻退出循环。
(5)此处是判断用户是否存在的条件,如果正常结束 for循环,则说明没用找到用户。

第9题:

String s="zhang san,li si,wang wu"; 按字母顺序对姓名


正确答案:
  

第10题:

定义结构体数组: struct stu { int num; char nameE20]; }X[5]={1,"LI",2,"ZHAO",3,"WANG",4," ZHANG",5,"LIU"); for(i=1;i<5;i++) printf("%d%c",x[i].num,x[i].name[2]); 以上程序段的输出结果为( )。

A.2A3N4A5U

B.112A3H4I

C.1A2N3A4U

D.2H3A4H5I


正确答案:A
本题主要考查结构体数组的使用。x[i].num为结构体x[i]中的hum成员,x[i].num[2]是结构体x[i]中name成员的第3个元素。程序执行循环过程时:第1次循环,i=1,输出x[i].num,x[1].name[2]的值;第2次循环,i=2,输出x[2].num,x[2].name[2]的值,即3N;第3次循环,i=3,输出X[3].hum,x[3].name[2]的值,即4A;第4次循环,i=4,输出x[4].num,x[4].name[2]的值,即5U。

更多相关问题