C) String s=”你好”;int i=3; s=i+s;
D) String s="你好”;int i=3; s=i+;
E) String s=null; int i=(s!=null)&&(s。length〉0)?s。length():0;
18.给定下列程序:
public class Test
{
public static void main(String args[]){
String str=new String("World”);
char ch[]={'C’,’e’,’l','l’,’o'};
change(str,ch);
System。out.println(str+”and"+ch);
}
public static void change(String str,char ch[]){
str="Changed”;ch[0]=’H';
}
};
上述程序的运行结果应该是?( )
A) World and Cello B) World and Hello
C) Changed and Hello D) Changed and Cello
19.在 java 语言中,下列表达式返回 true 的是哪些项目。( )
A) ”hello"=="hello" B) "word"。equals("word")
C) "john”="john” D) ”john”.equals(new Button(”john"))
20.下面的哪些程序片断可能导致错误?( )
A) String s=”Hello"; B) String s="Hello”;
String t="World"; String t;
String k=s+t; t=s[3]+”one”;
C) String s=”Hello”; D) String s=”Hello World”;
String standard = s。toUpperCase(); String t=s—”World";
21.在 java 语言中,下列语句中正确的是哪个?( )
A) String temp[]=new String{”a” ”b” ”c"};
B) String temp[]={"a" "b" ”c"};
C) String temp={”a” "b” ”c"};
D) String temp[]={”a”,”b",”c"};
22.下面的哪些叙述为真? ( )
A) equals()方法判定引用值是否指向同一对象。
B) == 操作符判定两个分立的对象的内容和类型是否一致.
C) equals()方法只有在两个对象的内容一致时返回 true。
D) 类 File 重写方法 equals()在两个分立的对象的内容和类型一致时返回 true。
23.关于以下程序段,正确的说法是
1. String s1="Hello”;
2. String s2=”Hello”;
3. if(s1= =s2)
4. System。out。println(”s1= =s2");
5. if (s1.equals(s2))
评论0
最新资源