首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello";
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello";
admin
2012-12-13
30
问题
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace (’r’,’m’); System.out.println(s); } }
选项
A、hello
B、HELLO
C、hemmo
D、HEMMO
答案
A
解析
String类的replace (char oldChar,char newChar)函数的作用是返回一个新的字符串,它是通过用newChar替换此字符串中出现的所有oldChar而生成的。返回的是新字符串,但是原字符串变量的值并未发生改变。因此,输出的是“hello”而不是“hemmo”。如果替换语句换为: s=s.replace(’l’,’m’);,则输出“hemmo”。
转载请注明原文地址:https://jikaoti.com/ti/jq80FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
考生文件夹下存在一个文件PY103.py,请写代码替换横线,不修改其他代码,实现以下功能:编写一个函数,使之能够实现字符串的反转。将字符串"goodstudy"输入到函数中,运行并输出结果。试题程序:#请在_________处使用一行代码或表达式替换
以下关于Python字典变量的定义中,正确的是()。
以下变量名中,符合Python语言变量命名规则的是()。
下面关于Python语言的说法正确的是()。
以下程序的输出结果是()。s=2foriinrange(1,10):S+=iprint(s)
以下不是Python所使用特殊含义符号的是()。
设线性表的长度为n。在最坏情况下,比较次数为n-1的算法是()。
random库采用更多的伪随机数序列生成算法是()。
数据结构作为计算机的一门学科,主要研究数据的逻辑结构、对各种数据结构进行的运算,以及
给出下列的程序段,则哪个选项是类A合理的内部类?()classA{protectedinti;A(inti){this.i=i;
随机试题
眶内海绵状血管瘤的病理和临床描述中,错误的是
水电站中动力渠道有非自动调节渠道和自动调节渠道两种,下面说法正确的是()。
根据《水利水电工程等级划分及洪水标准》SL252—2000,水利水电工程等别划分依据是()。
某基金在新股申购过程中,发现现金头寸不足,要求头寸复核岗位的员工修改初步询价信息,但由于员工疏忽未予修改,导致申购无效。该风险属于()。
按企业所得税法规定,企业的下列账务处理中,税务师在进行企业所得税汇算清缴时,应作纳税调整增加的有()。
股份有限公司不得收购本公司的股份,但是以下情形除外()。
企业以经营租赁方式租入的固定资产发生的改良支出,应直接计入当期损益。()
新闻是客观的报道,评论是主观的判断,评论要想摆脱主观臆断而尽可能保持客观理性,必然以新闻事实为基础,而不是依靠自己的想象。这决定了评论永远只能跟在新闻的后面,根据新闻事实,作出相应的评论和价值判断,而不能跑在新闻的前面,不能作出超越新闻事实的判断,不能根据
下列不属于儿童少年肌肉特点的是( )
SecuritiesandExchangeCommission
最新回复
(
0
)