题目内容

4、下列代码( )会出错。1) public void modify() {2) int I, j, k;3) I = 100;4) while ( I > 0 ) {5)j = I * 2;6) System.out.println (" The value of j is " + j );7) k = k + 1;8) I--;9) }10}

A. line 4
B. line 6
C. line 7
D. line 8

查看答案
更多问题

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

答案查题题库