题目内容

给出以下代码,请问该程序的运行结果是什么?public class Example{static String s1;static String s2;public static void main(String args[]){s2=s1+s2;System.out.println(s2);}}

A. 代码编译失败
B. 运行期错误,抛出NullPointerException异常
C. 打印输出nullnull
D. 代码编译成功,打印输出内容为空白行

查看答案
更多问题

给出以下代码,请问该程序的运行结果是什么?public class Example{private int i=giveMeJ();private int j=10;private int giveMeJ(){return j;}public static void main(String args[]){System.out.println((new Example()).i);}}

A. 第8行代码编译错误
B. 第2行代码编译错误
C. 打印输出0
D. 打印输出10

给出以下代码,请问该程序的运行结果是什么?public class Example{private int j=10;private int i=giveMeJ();private int giveMeJ(){return j;}public static void main(String args[]){System.out.println((new Example()).i);}}

A. 第8行代码编译错误
B. 第2行代码编译错误
C. 打印输出0
D. 打印输出10

给出以下代码,请问该程序的运行结果是什么?public class Example{private int i=j;private int j=10;public static void main(String [] args){System.out.println((new Example()).i);}}

A. 第5行代码编译错误
B. 第2行代码编译错误
C. 打印输出0
D. 打印输出10

给出以下代码,请问该程序的运行结果是什么?public class Example{public static void main(String [] args){String s;System.out.println("s="+s);}}

A. 无内容输出
B. 代码编译失败
C. 打印输出null
D. 打印输出s=null

答案查题题库