1、if (i % 3 = 0) System.out.println(i);空白处以下选项中,空白处可以填入的代码是。A. if (count+ = 10) break;B. if (+count C. if (count+ continue;D. if (+count B4.运行下面程序:String strArr = “aaa, “b, “cc ;Arrays.sort(strArr, new Comparator() public int compare(String o1, String o2) return o2 pareTo(o1););System.out.println(Arra
2、ys.toString(strArr);A.aaa, b, ccB.cc, b, aaaC.b, cc, aaaD.aaa, cc, b5. 对数组int arr = 52, 93, 16, 67, 36, 92, 26, 12, 25, 92 用插入排序法由小到大进展排序,经过3轮排序后,数组arr的值为:A. 12,16,25,52,93,26,67,36,92,92B. 12,16,25,67,36,92,26,52,93,92C. 16,52,67,93,36,92,26,12,25,92D. 16,36,52,67,93,92,26,12,25,926.以下代码的输出结果是:publ
3、ic class StaticFoo int num;static int x;StaticFoo foo1 = new StaticFoo ();foo1.num+;foo1.x+;StaticFoo foo2 = new StaticFoo ();foo2.num+;foo2.x+;StaticFoo foo3 = new StaticFoo ();foo3.num+;foo3.x+;StaticFoo.x+;System.out.print(foo3.num+,);System.out.println(foo3.x);A.3,3B.1,3C.3,4D.1,47.以下代码编译和运行的结果是
4、java.util.List list = new java.util.ArrayList();list.add(new B();list.add(new C();for (A a : list) a.x();a.y();interface A void x();class B implements A public void x() public void y() class C extends B A.代码运行没有输出B.运行时抛出异常C.代码a.y();行,编译错误D.代码java.util.List8.请看以下代码:class ClassA class ClassB extends C
5、lassA class ClassC extends ClassA public class TestClassA p0 = new ClassA();ClassB p1 = new ClassB();ClassC p2 = new ClassC();ClassA p3 = new ClassB();ClassA p4 = new ClassC();可以在1;D. byte b1 = 10;byte b=+b1;11.类Super及Sub定义如下:public class Super private void f() System.out.println(“Super.f();public v
6、oid g() f();public void k() public class Sub extends Super System.out.println(“Sub.f();运行以下语句:Super obj = new Sub();obj.g();obj.k();A. Sub.f()Sub.f()B. Sub.f()Super.f()C. Super.f()D. Super.f()12.以下代码的输出结果是String test = “a1b2c3;String tokens = test.split(“d);for (String s : tokens)System.out.print(s
7、+ “);A.a b cB.1 2 3C.a1b2c3D.a1 b2 c313.运行以下程序:String str = “*java*java*java*;String str1 = “java;int index = 0;while (index = str.indexOf(str1, index) != -1) System.out.print(index+);index += str1.length();控制台输出的结果是:A. 1 8 17B. 2 9 18C. 5 12 21D. 6 13 2214.运行下面程序:public class Footry test();System.o
8、ut.println(“condition 1); catch (ArrayIndexOutOfBoundsException e) System.out.println(“condition 2); catch (Exception e) System.out.println(“condition 3); finally System.out.println(“finally);public static void test() String str = “cc;str pareTo(“abc);A.condition 1finallyB.condition 2C.condition 1co
9、ndition 3D.condition 1condition 215.以下代码的作用说法不正确的选项是:class Card implements java.io.SerializableA.开启序列化功能,使得Card类的对象可以存储到文件中B.开启序列化功能,使得Card类的对象可以在网络上传输C.使得Card类的子类的对象可以被序列化D.导致Card的子类的对象不可以被反序列化16. try里有一个return语句,那么紧跟在这个try后的finally里的代码执行的情况是:A.会执行,在return前执行B.会执行,在return后执行C.不会执行D.会抛出异常17. 关于Java
10、异常,以下说法错误的选项是。A.异常是定义了程序中遇到的非致命的错误,而不是编译时的语法错误B.trycatch语句中对try 内语句监测,如果发生异常,那么把异常信息放入Exception类的对象中C.throws 用来表示一个方法有可能抛出异常给上一层,那么在调用该方法时必须捕捉异常,否那么无法编译通过D.Main方法不可以使用 throws 抛出异常18. 以下关于IDE开发环境Eclipse,说法错误的选项是:A. Eclipse可以通过插件plugin的方式扩展其功能。B. Eclipse联盟是由IBM公司捐资组建的。C. Eclipse使用了SWT图形界面技术。D. Eclipse
11、的运行不需要有JRE的支持。19. 运行以下代码:int oneArr = 2, 11, 26, 27, 37, 44, 48, 60 ;int twoArr = 19, 35, 49, 55, 58, 75, 83, 84, 91, 93 ;int threeArr = new intoneArr.length + twoArr.length;int p = 0, q = 0;while (p oneArr.length & q twoArr.length) threeArrp + q =oneArrp twoArrq ? oneArrp+ : twoArrq+;if (p oneArr.l
12、ength) System.arraycopy(oneArr, p, threeArr, p + q, oneArr.length p);else if (q System.out.println(s);如果程序输出的结果是4247,那么在处应该填入代码是。A.String s = “123456789;s = (s-123).replace(1,3,24) “89;B.StringBuffer s = new StringBuffer(“123456789);s.delete(0,3).replace( 1,3, “24).delete(4,6);C.StringBuffer s = new
13、 StringBuffer(“123456789);s.substring(3,6).delete( 1 ,3).insert( 1, “24);D.StringBuilder s = new StringBuilder(“123456789);s.substring(3,6).delete( 1 ,2).insert( 1, “24);35. 下面关于数组的声明语句中,有编译错误的选项是:A. int arr = new int1,2,3;B. int arr = null;arr = 1,2,3,4,5;C. int arr = new int1,2,3,4,5,6D. int arr = new int2;36. 以下赋值语句中,会有编译错误的选项是。A. int a = 8888888888;B. char b = 1000+300;C. byte c = 100+30;D. int d = a+b+c;AC37. 下面的方法属于StringBuffer的是:A. sizeB. insertC. deleteD. lengthBCD38.查看如下代码:class A protected int method (int a, int b)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1