java选择题string_java,string类练习题.doc

java,string类练习题

java,string类练习题

一、选择题

1. 下列String类的方法返回指定字符串的一部分

A. extractstring B. substring C. Substring D. Middlestring

2.下列哪一个是正确的

A) HashTable的关键字和值都允许为null

B) HashTable的关键字和值都不允许为null

C) HashTable的关键字允许为null,值不允许为null D) HashTable的关键字不允许为null,值允许为null.对于下列代码:

String str1=“java”; String str2=“java”;

String str3=new String;

StringBuffer str4=new StringBuffer; 以下表达式的值为true的是 A) str1= =str2; C) str2= =str3;

B) str1= =str4; D) str3= =str4;

4.以下程序段输出结果的是

public class Test {

public static void main{String str=“ABCDE”;str.substring;str.concat;

System.out.print; }

}

A) DE B) DEXYZ C) ABCDED) CDEXYZ.对于下列代码:

public class Example{

String str=new String; char ch[]={‘d’,’b’,’c’};

public static void main{ }

public void change{ str=“world”;ch[0]= ‘a’;

}

Example ex=new Example; ex.change;

System.out.println;

}

B) hello and a

输出结果是: A) hello and d

C) world and d D) world and a.以下代码的运行结果是哪一项。

public class StringTest { } A)A.A C)A.B

B)B.A D)B.B

public static void mb_operate {}

public static void main { }

String a=“A”; String b=“B”; mb_operate;

System.out.println; x.concat; y=x;

7.以下代码的运行结果是哪一项。

public class StringArray Test {}

public static void mb_swap {}

public static void main { }

B)21 D)23

String [] s={“1”,”2”}; mb_swap;

System.out.print; if return; String t=s[0]; s[0]=s[1]; s[1]=t;

A)20 C)22

8.以下代码的运行结果是哪一项。

publicclassTestGetChars{

publicstaticvoidmain{

String myString = new String; char [] yourString = new char[16];

myString.getChars;

System.out.println;

System.out.println;

} }

A)Hello World! B)Hello World!

Hello Hello! C)Hello World! D)World

World

World

9.以下代码的运行结果是哪一项。

publicclassTestStringContructor{

publicstaticvoidmain{byte [] b = {49,50,51,52,53};} A)45555

B)12345

C

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值