当前位置:首页 >课程 >Java程序设计

1、编译及运行以下代码,下列选项哪个是正确的 String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));

A.输出Bic
B.输出ic
C.输出icy
D.编译错误

参考答案:请扫码使用小程序查看答案

2、下面哪个是对字符串String的正确定义

A.String s1=null;
B.String s2='null';
C.String s3=(String)'abc';
D.String s4=(String)'\uface';

参考答案:请扫码使用小程序查看答案

3、字符串s=”Java”,找出字母v在字符串s中的位置,以下哪个选项是正确的

A.mid(2,s);
B.charAt(2);
C.indexOf(s);
D.s.indexOf('v');

参考答案:请扫码使用小程序查看答案

4、给出以下变量定义,以下哪个语句是正确的 String s1=new String("Hello"); String s2=new String("there"); String s3=new String();

A.s3=s1 + s2;
B.s3=s1 - s2;
C.s3=s1 & s2;
D.s3=s1 && s2;

参考答案:请扫码使用小程序查看答案

5、以下哪个方法可以返回字符串的长度:

A.length()
B.compareto()
C.indexof()
D.touppercase()

参考答案:请扫码使用小程序查看答案