请看看下面两道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
1个回答 分类:综合 2014-12-15

问题解答:

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