首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序执行后,屏幕上显示的应是( )。 public class Test{ public static void main(String[ ] args) { char ch1[]={’B’,’
下面程序执行后,屏幕上显示的应是( )。 public class Test{ public static void main(String[ ] args) { char ch1[]={’B’,’
admin
2013-03-01
51
问题
下面程序执行后,屏幕上显示的应是( )。 public class Test{ public static void main(String[ ] args) { char ch1[]={’B’,’e’,’i’,’j’,’i’,’n’,’g’}; char ch2[]={’B’,’e’,’i’,’j’,’i’,’n’,’g’,’2’,’0’,’0’,’8’}; String s1 = new String(ch1); String s2 = new String(ch2, 0, 7); System.out.println(sl.equals(s2)); } }
选项
A、true
B、false
C、Beijing
D、编译错误
答案
1
解析
首先可以通过字符数组来生成一个字符串对象:String(char[] value);
String(char valne, int startIndex, int numChars);其中,startlndex指定字符串在数组中的起始下标,numChars表示字符个数。
然后再测试字符串是否相等,可调用equals()方法,两串相等则返回true,否则返回false。
转载请注明原文地址:https://www.kaotiyun.com/show/Qj2p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
下面对软件测试描述错误的是()。
下面叙述中正确的是()。
下面不属于Python的标准库的是()。
假设现在是2018年10月1日的下午2时20分7秒,则下面程序的输出结果为()。importtimeprint(time.strftime(”%y-%m-%d@%H-%M-%S”,time.gmtime()))
结构化程序的3种基本控制结构是()。
下面能作为软件设计工具的是()。
随机试题
常见的寒热症状不包括
组织竞争优势的源泉是()
丹毒的致病菌是
能同时阻断中枢和外周性的D2受体的促胃肠动力药是()。
下列关于单位工程施工组织设计的说法,正确的是()。
施工现场围挡高度在市区主要路段不宜低于()m,在一般路段不低于()m。
下列有关平衡计分卡与企业战略管理的说法中,不正确的是()。
"Iwanttocriticizethesocialsystem,andtoshowitatwork,atitsmostintense."VirginiaWoolf’sprovocativestatementabo
ThethirdofMarch,1887,threemonthsbeforelwassevenyearsold,wasthemostimportantdayIrememberinallmylife.Onth
Thefrontmatterofabookconsistsofthetitle,subtitle,tableofcontents,andpreface.Butthe【C1】______ofreaderswhopay
最新回复
(
0
)