Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()A、 An exception is thrown at runtime.B、 1C、 4D、 Compilation fails.E、 0

题目

Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()

  • A、 An exception is thrown at runtime.
  • B、 1
  • C、 4
  • D、 Compilation fails.
  • E、 0

相似考题
更多“Given:   11. Str”相关问题
  • 第1题:

    下列程序的运行结果为

    #include<stdio.h>

    void abc(char*str)

    { int a,b;

    for(a=b=0;str[a]!='\0';a++)

    if(str[a]!='c')

    str[b++]=str[a];

    str[b]='\0';}

    void main()

    { char str[]="abcdef";

    abc(str);

    printf("str[]=%s",str); }

    A.str[]=abdef

    B.str[]=abcdef

    C.str[]=a

    D.str[]=ab


    正确答案:A
    解析:本题考查了用字符指针引用字符数组中的字符及对字符的操作。函数abc()的for语句执行过程是:从字符指针str所指向的字符数组的第一个元素开始,逐一判断字符是否为'c',若不是就执行一次数组元素的赋值过程,若字符为'c'就不执行。

  • 第2题:

    设有定义charstr[80]以下不能将输人数据nrst\nsecond\<CR)读取到数组str的语句是( )。

    A.cin.get(str,strlen(str));

    B.cin.getline(str,strlen(str));

    C.cin>>str;

    D.dn.read(str,strlen(str));


    正确答案:D
    解析: 本题考查cin流对象的几种成员函数get,getline,read及流提取符>>的使用规则。

  • 第3题:

    以下C程序段的输出结果是(30)。 include void abc(char *str){ int a, b;

    以下C程序段的输出结果是(30)。 #include <stdio. h> void abc(char *str){ int a, b; for(a=b=0;str[a]!='\O';a++)if(str[a]!='c') str[b++]=str[a]; str[b]='\O'; } void main(){ char str[]="abcdef"; abc(str); printf("str[]=%s",str); }

    A.str[]=a

    B.str[]=ab

    C.str[]=abdef

    D.str[]=abcdef


    正确答案:C
    解析:本试题核心在于子函数的for循环。For循环将整个字符串中的字符处理一遍,每次处理时,函数的基本工作是将除字母c之外的字符重新赋值,然后a++,b++,继续处理下一个字符。对于字母c不赋值,且只有a++而b不变。可见for循环的目的只是将字母c剔除。

  • 第4题:

    设有char str[80];以下不能将输入数据first\nsecond\n读取到数组str中的语句是A.cin.get(str

    设有char str[80];以下不能将输入数据first\nsecond\n<CR>读取到数组str中的语句是

    A.cin.get(str,strlen(str));

    B.cin.getline(str,strlen(str));

    C.cin>>str;

    D.cin.read(str,strlen(str));


    正确答案:B
    解析:本题考察C++中输入输出流对象的一些常用成员函数的用法。其中get和getline的区别在于getline读取中以"\n"作为输入结束符。故本题中getline只能接收第一个换行符之前的字符,即first。后面的字符被丢弃。因此正确答案应为B。

  • 第5题:

    执行下面的程序,单击窗体后在窗体上显示的结果是 ______。Private Sub form_ Click() Dim Str1 As String, Str2 As String Dim Str3 As String, I As Integer Str1 = "e" for I = t To 2 Str2 = Ucase (Str1) Str1 = Str2 & Str1 Str3 = Str3 & Str1 str1 = Chr (Asc(Str1) + I) Next I Print Str3End Sub

    A.EeFF

    B.eEfF

    C.EEFF

    D.eeFF


    正确答案:A
    解析:本题的难点是熟悉下列字符串处理内部函数:Asc(x)为求单个字符ASCII代码函数,Chr[$](x)返回以x为ASCII代码值的字符,Ucase[$](x)将x字符串中所有小写字符改为大写字符。

  • 第6题:

    下列描述中,不能正确给字符数组str定义和赋值的是( )。

    A、char str[]={"abcdefghijklmn "};

    B、char str[10];str={" abcdefghijklmn "};

    C、char str[10]={"abcdefghijklmn"};

    D、char str[10];strcpy(str,"abcdefghijklmn");


    参考答案BCD

  • 第7题:

    在下列语句中,正确的是( )

    A.static char str[]="China";

    B.static char str[];str="China";

    C.static char str1[5],str2[]={"China"};str1=str2;

    D.static char str1[],str2[];str2={"China"};strcpy(str1,str2);


    正确答案:A

  • 第8题:

    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() 

    • A、 True
    • B、 Not true
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error at line 12.
    • E、 Compilation fails because of an error at line 19.

    正确答案:A

  • 第9题:

    在C语言中,将字符串str2连接到str1尾部的操作正确的是()

    • A、str1=str2
    • B、strcpy(str1,str2)
    • C、str1+str2
    • D、strcat(str1,str2)

    正确答案:D

  • 第10题:

    java中 String str = "hello world"下列语句错误的是()。

    • A、str+=’ a’
    • B、int strlen = str.length
    • C、str=100
    • D、str=str+100

    正确答案:A,B,C

  • 第11题:

    多选题
    Given: 11. 16. Which three EL expressions, inserted at line 16, are valid and evaluate to "d"?()
    A

    ${map.c}

    B

    ${map[c]}

    C

    ${map[c]}

    D

    ${map.map.b}

    E

    ${map[map.b]}


    正确答案: B,E
    解析: 暂无解析

  • 第12题:

    单选题
    Given the following code fragment:      1) String str = null;  2) if ((str != null) && (str.length() > 10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null) & (str.length() < 5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()
    A

     line 1

    B

     line 2

    C

     line 5

    D

     line 8


    正确答案: C
    解析: 此题需要将代码仔细看清楚,查询没有逻辑错误,if …else的使用没有问题,也没有拼写错误,错误在于第5行的“与”操作符的使用,逻辑操作符(logical operator)的“与” 应该是&&,而&是位逻辑操作符(bitwise logical operator)的“与”,使用的对象不一样,逻辑操作符的“与”的左右操作数都应该是布尔型(logical boolan)的值,而位逻辑操作符的左右操作数都是整型(integral)值。

  • 第13题:

    字符串"\\\"ABCDEn"\"\\"的长度是( )。

    A.strcpy(str2,str1)

    B.strcpy(str3,str1)

    C.strcpy(str4,str1)

    D.strcpy(str5,str1)


    正确答案:C
    解析: strcpy(s1,s2)函数的功能是将字符串s2复制到字符串s1中(注意:要保证s1存储区能容纳下 s2字符串)。

  • 第14题:

    Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()()

    A.

    B.

    C.

    D.

    E.

    F.


    参考答案:A

  • 第15题:

    Given:11.//insertcodehere12.&e

    Given:

    11.//insertcodehere

    12.privateNmin,max;

    13.publicNgetMin(){returnmin;}

    14.publicNgetMax(){returnmax;}

    15.publicvoidadd(Nadded){

    16.if(min==null||added.doubleValue()<min.doubleValue())

    17.min=added;

    18.if(max==null||added.doubleValue()>max.doubleValue())

    19.max=added;

    20.}

    21.}

    Whichtwo,insertedatline11,willallowthecodetocompile?()


    参考答案:B, D

  • 第16题:

    char str[ ]= "Hello";

    char *p=str;

    int n=10;

    sizeof(str)=( )

    sizeof(p)=( )

    sizeof(n)=( )

    void func(char str[100])

    { }

    sizeof(str)=( )


    正确答案:
     

  • 第17题:

    下列语句中,正确的是______。

    A.static char str[]="China";

    B.static char str[];str="China";

    C.static char str1[5],str2[]={"China"};strl=str2;

    D.static char str1[],str2[];str2={"China"};strcpy(str1,str2);


    正确答案:A

  • 第18题:

    若有下列说明,则( )不是对strcpy库函数的正确的调用。strcpy库函数用于复制一个字符串:char*str1="abcdt",str2 [10],*str3="hijklmn",*str4[2],*str5="aaaa";

    A.strcpy(str2,str1)

    B.strcpy(str3,str1)

    C.strcpy(str4,str1)

    D.strcpy(str5,str1)


    正确答案:C
    解析:strcpy(s1,s2)函数的功能是将字符串s2复制到字符串s1中(注意:要保证s1存储区能容纳下s2字符串)。

  • 第19题:

    当运行以下程序时,输入abcd,程序的输出结果是:( )。

    insert(char str[])

    {int i;

    i=strlen(str);

    while(i>0)

    {str[2*i]=str[i];str[2*i-1]='*';i--;}

    printf("%s\n",str);

    }

    main()

    {char str[40];

    scanf("%s",str);insert(str);

    }


    正确答案:a*b*c*d*
    a*b*c*d* 解析:字符处理函数strlen()测试字符串常量的长度,不包括‘\0’在内。因此,函数insert()实现了将字符数组中每个非‘\0’的字符后插入字符‘*’的功能。故输出结果是a*b*c*d*。

  • 第20题:

    两个字符串String str1,str2;错误的连接二者的方式是()

    • A、str1+str2
    • B、str1.str2
    • C、str1.contat(str2)
    • D、str2.contat(str1)

    正确答案:B

  • 第21题:

    Given the following code fragment:      1) String str = null;  2) if ((str != null) && (str.length() > 10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null) & (str.length() < 5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    

    • A、 line 1
    • B、 line 2
    • C、 line 5
    • D、 line 8

    正确答案:C

  • 第22题:

    设已定义:char str1[10],str2[10]=”Fujian”;则能将字符串”Fujian”赋给数组str1的正确语句是()

    • A、str1=”Fujian”
    • B、strcpy(str1,str2)
    • C、strcpy(str2,str1)
    • D、str1=str2

    正确答案:B

  • 第23题:

    单选题
    11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What is the result?()
    A

     Au exception is thrown at runtime.

    B

     “String is empty” is printed to output.

    C

     Compilation fails because of au error in line 12.

    D

     “String is not empty” is printed to output.


    正确答案: A
    解析: 暂无解析