请看看下面两道Java题,选择哪个答案,并请说明原因!

请看看下面两道Java题,选择哪个答案,并请说明原因!
1.指出正确的表达式().
A. byte = 128;
B. Boolean = null;
C. long l = 0xfffL;
D. double = 0.9239d;
2.指出下列程序运行的结果
public class Example{
String str=new String("good");
char[]ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
System.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';
}
}
A.good and abc
B.good and gbc
C.test ok and abc
D.test ok and gbc
jghleon 1年前 已收到1个回答 举报

fengchun_78 幼苗

共回答了16个问题采纳率:93.8% 举报

1.C 答案A 超出了范围 bye的取值范围是-128-127
答案B boolean行只有两种取值true和false没有null
答案D 没有变量名
2.B
因为字符串作为参数传递的时候,其实传递的是一个字符串的副本,所以对字符串的修改不会影响到原来的取值, 而数组在作为参数传递的时候,传递的是引用, 所以对于数组的修改, 会影响到数组原来的取值

1年前

4
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.658 s. - webmaster@yulucn.com