Java练习题及答案
Java试题及答案一、 选择1.下列程序段执行后的结果是( A )。 String s=new String("abcdefg");for(int i=0;i<s.length();i+=2){
Java 试题及答案 一、选择 1.(A) 下列程序段执行后的结果是。 Strings=newString("abcdefg"); for(inti=0;i<s.length();i+=2){ System.out.print(s.charAt(i)); } A)acegB)ACEGC)abcdefgD)abcd 2.int[]x={12,35,8,7,2};,Arrays.sort(x)x(A). 有整型数组:则调用方法后,数组中的元素值依次是 A)2781235B)1235872 C)3512872D)8712352 3.C 指出正确的表达式 Abyte=128; BBoolean=null; Clongl=0xfffL; Ddouble=0.9239d; 4.:B 指出下列程序运行的结果 publicclassExample{ Stringstr=newString("good"); char[]ch={'a','b','c'}; publicstaticvoidmain(Stringargs[]){ Exampleex=newExample(); ex.change(ex.str,ex.ch); System.out.print(ex.str+"and"); Sytem.out.print(ex.ch); } publicvoidchange(Stringstr,charch[]){ str="testok"; ch[0]='g'; } } Agoodandabc Bgoodandgbc Ctestokandabc Dtestokandgbc 5.,A 运行下列程序会产生什么结果 publicclassXextendsThreadimplementsRunable{ publicvoidrun(){ System.out.println("thisisrun()"); } publicstaticvoidmain(Stringargs[]) { Threadt=newThread(newX());

