首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请阅读下面程序 publicclassExampleStringBuffer{ publicstaticvoidmain(String[]args){ StringBuffersb=newStringBuffer(“test”): System.Out.p
请阅读下面程序 publicclassExampleStringBuffer{ publicstaticvoidmain(String[]args){ StringBuffersb=newStringBuffer(“test”): System.Out.p
admin
2013-12-02
11
问题
请阅读下面程序
publicclassExampleStringBuffer{
publicstaticvoidmain(String[]args){
StringBuffersb=newStringBuffer(“test”):
System.Out.println(“buffer=”+sb);
System.out.println(“length=”+sb.1ength
());})
程序运行结果中在”length=”后输H1的值是( )。
选项
A、10
B、4
C、20
D、30
答案
B
解析
本题对StringBuffer(Stringstr)构造方法,用str给出字符串的初始值。并分配16个字符的缓存。因此,字符串sb的初始值是“test”,并且包含16个字符的缓存。length()方法用来获得字符串长度,不包含缓存。故程序运行结果中在“length=”后输出的值应该是字符串sb的长度。即4。
转载请注明原文地址:https://kaotiyun.com/show/OLID777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
潘某不服某卫生局的行政处罚决定,向法院提起诉讼。诉讼过程中,卫生局撤销了原处罚决定,潘某遂向法院申请撤诉,法院作出准予撤诉的裁定。一周后,卫生局又以同一事实和理由作出了与原处罚决定相同的决定。下列哪一种说法是正确的?()
完全垄断企业可以以()方法定价,以获得最大垄断利润。
下列选项中,有关科技词汇与出处对应关系错误的是()。
《桃花源记》中描述:“缘溪行,忘路之远近。忽逢桃花林,……林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田美池桑竹之属。”“桃花源”的地形最可能是()。
不动产物权的权利变动,通常以()为公示方法。
税收的基本特征不包括()。
世界贸易组织的各项协议所涉及的领域不包括()。
下面对商鞅变法论述不正确的是()。
如果你购买了W公司股票的欧式看涨期权,协议价格是每股20元,合约期限为3个月,期权价格为每股1.5元。若W公司股票市场价格在到期日为每股21元,则你将()。
在T-SQL中,提取游标curl第5行数据的语句是【6】ABSOLUTE5FROMcurl…
随机试题
不属于有机磷中毒临床表现的是
下列哪种情形属于自首?
甲公司为丙公司的全资子公司,于1992年11月经乙市市场监督管理局核准成立,注册资本1000万元,甲公司自开始经营以来内部管理一直存在严重问题,长年亏损。2017年度审计报告显示甲公司资产负债率超出100%,甲公司有签订劳动合同的职工27人,至今拖欠职工
计算机病毒是(52)。
操作系统中的文件管理系统为用户提供的功能是()。
假设某台计算机的内存容量为256MB,硬盘容量为40GB。硬盘容量是内存容量的
Whyisthemansoannoyed?
Whenisthefilmfestivalscheduledtostart?
TodaythecaristhemostpopularsortoftransportationinalloftheUnitedStates.Ithascompletelyre【77】thehorseasam【7
【S1】【S2】
最新回复
(
0
)