题目内容

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

给出以下代码,请问该程序的运行结果是什么?public class Example{public static void main(String args[]){String str=new String("World");char ch[]={'H','e','l','l','o'};change(str,ch);System.out.print(str+"and"+" ");for(int i=0; i

A. 打印输出World and Hello
B. 打印输出World and Cello
C. 打印输出Changed and Hello
D. 打印输出Changed and Cello

给出以下代码,请问该程序的运行结果是什么?public class Example{public static Object getIt(){Object rg=new IntegerC. ;Object dg[][]=new Object[1][2];dg[0][1]=rg;dg[0][0]=rg;rg=null;return rg;}}

A. Example类编译失败。
B. getIt()方法不能声明为静态方法。
C. rg对象在调用getlt()方法后,可以被垃圾回收器回收。

答案查题题库