java题库 联系客服

发布时间 : 星期四 文章java题库更新完毕开始阅读05e8f345d1d233d4b14e852458fb770bf68a3b18

(1)无内容输出 (2) 代码编译失败 (3)打印输出null (4)打印输出s=null 答案:(2)

64:给出以下代码,请问在程序的第2行和第4行分别插入哪条语句,该程序可成功运行? 1.public class Example{ 2.

3.public static void main(String args[]){ 4.

5.System.out.println(\ 6.} 7.}

请选择所有正确答案:

(1)char c;语句插入到第2行 (2)char c;语句插入到第4行 (3)char c=’f’; 语句插入到第2行 (4)char c=’f’; 语句插入到第4行 (5)static char c; 语句插入到第2行 (6)char c=new char();语句插入到第4行 答案:(4)(5)

65:给出以下代码,请问该程序的运行结果是什么?

public class Example{

public static void add3(Integer i){ 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()); } }

请选择一个正确答案: (1)代码编译失败 (2)打印输出0 (3)打印输出3

(4)运行期,第2行抛出异常 答案:(2)

66:给出以下代码,请问该程序的运行结果是什么? class Example {

public static void main(String args[]){ (new Example()).myMethod(); }

void myMethod(){ int x,y; x=5;y=3;

System.out.print(\ switchCoords(x,y);

System.out.print(\ }

void switchCoords(int x,int y){ int temp; temp=x; y=temp;

System.out.print(\ } }

请选择一个正确答案:

(1)打印输出(5,3)(5,3)(5,3) (2)打印输出(5,3)(3,5)(3,5) (3)打印输出(5,3)(3,5)(5,3) 答案:(3)

67:给出以下代码,请问该程序的运行结果是什么? class Example{ String myString=\

public static void main(String args[]){ Example myObj=new Example(); myObj.stringModifier(myObj.myString); System.out.print(\ }

void stringModifier(String theString){ theString=theString+\ System.out.print(theString); } }

请选择一个正确答案: (1)打印输出12 1 (2)打印输出12 12 (3)打印输出1 12 答案:(1)

68:给出以下代码,请问该程序的运行结果是什么? public class Example{

public static void main(String args[]){ String str=new String(\ char ch[]={'H','e','l','l','o'}; change(str,ch);

System.out.print(str+\ for(int i=0; i