1、关于以下程序段,正确的说法是()。1. String s1=“a”+“b”;2. String s2=new String(s1);3. if(s1==s2)4. System.out.println(“= = is succeeded”);5. if (s1.equals(s2))6. System.out.println(“.equals() is succeeded”);
A. 行4与行6都将执行
B. 行4执行,行6不执行
C. 行6执行,行4不执行
D. 行4、行6都不执行
查看答案
2、下面程序运行结果为()public class test3 {public static void main(String args[]) {int count=0;for (int i=0;i<=100;i++)count+=count++;}System.out.println( count );}ABc D
A. 0
B. 7
C. 编译有错误
D. 其他答案
4、下面初始化数组语句()是不正确的。
A. int x[] = {1,2,3};
B. int x[3] = {1,2,3};
C. int[] x = {1,2,3};
D. int x[] = new int[]{1,2,3};
5、指出下列程序运行的结果 ( )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
2、若在某一个类定义中定义有如下的方法:finalvoid aFinalFunction( );则该方法属于( )。
A. 本地方法
B. 静态方法
C. 最终方法
D. 抽象方法