题目内容

给出以下代码,请问该程序的运行结果是什么?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)

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

A. 打印输出12 1
B. 打印输出12 12
C. 打印输出1 12

答案查题题库