- 首页
- 单选择
[单选择]What will be the output when you compile and execute the following program. The symbol ’ ?’ means space.
public class Base{
private void test() {
String aStr = “?One?”;
String bStr = aStr;
aStr.toUpperCase();
aStr.trim();
System.out.println(“[" + aStr + "," + bStr + "]“);
}
static public void main(String[] a) {
new Base().test();
}
}
Select most appropriate answer.
参观人数:752 ,参试人数:3,正确率:33%
该题的参考答案有:
4、[?One?,?One?]
通过String bStr = aStr;这句代码使bStr和aStr指向同一个地址空间,所以最后aStr和bStr的结果应该是一样,String类是定长字符串,调用一个字符串的方法以后会形成一个新的字符串。