题目内容

8、阅读以下代码:public class Foo{public static void main (String[] args){String s;System.out.println("s=" + s);}}输出结果应该是()。

A. 代码得到编译,并输出“s=”
B. 代码得到编译,并输出“s=null”
C. 由于String s没有初始化,代码不能编译通过
D. 代码得到编译,但捕获到NullPointException异常

查看答案
更多问题

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};

答案查题题库