给出以下代码,请问该程序的运行结果是什么?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
给出以下代码,请问该程序的运行结果是什么?public class Example{public static void add3( ){int val=i.intValue();val+=3;i=new Integer(val);}public static void main(String args[]){Integer i=new Integer(0);add3(i);System.out.println(i.intValue());}}
A. 代码编译失败
B. 打印输出0
C. 打印输出3
D. 运行期,第2行抛出异常
给出以下代码,请问该程序的运行结果是什么?class Example {public static void main(String [] args){(new Example()).myMethod();}void myMethod(){int x,y;x=5;y=3;System.out.print("("+x+","+y+")");switchCoords(x,y);System.out.print("("+x+","+y+")");} void switchCoords(int x,int y){int temp;temp=x;y=temp;System.out.print("("+x+","+y+")");}}
A. 打印输出(5,3)(5,3)(5,3)
B. 打印输出(5,3)(3,5)(3,5)
C. 打印输出(5,3)(3,5)(5,3)