t start class Turing extends Thread public void runo for(int i=0: i< 2: i++) System.out. printIn( A.由于go方法参数的形式不正确会有编译错误。 B. Turing类没有 strart方法,所以有编译错误。 C.编译并输出0和1 D.可以编译但运行出错。 39.如下那种Java的控件将不会引发动作事件( Action Event)? A. Button B. Menuitem C. Panel D. Checkboxmenulte 40.请选择合适的集合类型,这种类型应该具有所存储的元素是不能重复的、被排序的? provides that capability? A java uil. Map B java util. Set C java util. List D java util. Collection 41.编译 java Applet源程序文件将产生相应的结果文件,这些结果文件的扩展名是什么? A C. html 42.如果你试图编译并运行下面的代码将发生什么? public class My Class public static void main(String argvDI int anar[= new int[( 1, 2, 3] System.out. printIn (anar[ 1]) A.1 B.有错误anar引用之前必须被初始化。 D.有错误数组的尺寸必须被指定。 43.将一个十六进制数赋值给一个long类型的变量,正确的表达式是 A long number=345L B long number =0345 C long number =0345L D. long number= 0x345L 44.如果你试图编译并运行下面的代码将发生什么? public class Test t public static void main( String argo)[ String s= new String ("Bicycle") iBegin=1 har iend 3
t.start(); } } class Turing extends Thread { public void run() { for (int i = 0; i < 2; i++) { System.out.println(i); } } } A. 由于go方法参数的形式不正确会有编译错误。 B. Turing类没有strart方法,所以有编译错误。 C. 编译并输出0和1. D. 可以编译但运行出错。 39. 如下那种 Java 的控件将不会引发动作事件(ActionEvent)? A. Button B. MenuItem C. Panel D. CheckboxMenuItem 40. 请选择合适的集合类型,这种类型应该具有所存储的元素是不能重复的、被排序的? provides that capability? A. java.uil.Map B.java.util.Set C.java.util.List D.java.util.Collection 41. 编译 java Applet 源程序文件将产生相应的结果文件,这些结果文件的扩展名是什么? A. .java B. .class C. .html D. .exe 42. 如果你试图编译并运行下面的代码将发生什么? public class MyClass { public static void main(String argv[]) { int anar[] = new int[] { 1, 2, 3 }; System.out.println(anar[1]); } } A. 1 B. 有错误 anar 引用之前必须被初始化。 C. 2 D. 有错误数组的尺寸必须被指定。 43. 将一个十六进制数赋值给一个 long 类型的变量,正确的表达式是: A. long number = 345L; B. long number = 0345; C. long number = 0345L; D. long number = 0x345L. 44. 如果你试图编译并运行下面的代码将发生什么? public class Test { public static void main(String argv[]) { String s = new String("Bicycle"); int iBegin = 1; char iEnd = 3;
System. out printin(.substring(iBegin, iEnd)) ABC D. error: no method matching substring(int, char) 45. JPanel组件的默认布局管理器是哪一项? C. BorderLayout D. FlowLayc 46.如果你想查找"Java"字符串中v所在的位置? A. mid (2, S) B charAt(2) D. indexof(. v 47.下列哪一项不属于面向对象程序设计的基本要素? BCD 对象 方法 安全 48.下面程序的输出结果是。 public class ex2 public static void main( String[ args) for(int cnt=0; cnt<10; cnt++) System. out print(cnt); A.01234 C.012346789 49.给定下面的代码片段 2)if(str!=null)&&(str length(>10))i 34 " more than10°) ystemoutprintIn( "less than 5 ) 7)} 8)else( System.out. printIn("end");)
System.out.println(s.substring(iBegin, iEnd)); } } A. Bic B. ic C. icy D. error: no method matching substring(int,char) 45. JPanel 组件的默认布局管理器是哪一项? A. GridLayout B. CardLayout C. BorderLayout D. FlowLayour 46. 如果你想查找"Java"字符串中 v 所在的位置? A. mid(2,s); B. charAt(2).; C. s.indexOf('v'); D. indexOf(s,'v'); 47. 下列哪一项不属于面向对象程序设计的基本要素? A. 类 B. 对象 C. 方法 D. 安全 48. 下面程序的输出结果是。 public class ex2 { public static void main(String[] args) { for(int cnt=0;cnt<10;cnt++) { if(cnt==5) break; System.out.print(cnt); } } } A. 0 1 2 3 4 B. 6 7 8 9 C. 0 1 2 3 4 6 7 8 9 D. 5 49. 给定下面的代码片段: 1) String str = null; 2) if ((str != null) && (str.length() > 10)) { 3) System.out.println("more than 10"); 4) } 5) else if ((str != null) & (str.length() < 5)) { 6) System.out.println("less than 5"); 7) } 8) else { System.out.println("end"); }
哪些行会导致错误? A line 1 C line 5 D line 8 50.如果给出下面列声明 String s1=new String( Hello); String s2= new String(there") String s3=new String 下面的操作哪些是有效的? B.s3=s1-s2 C.s3=s1&s2; D.s3=s1&&s2 51.下面哪种注释方法能够支持 javadoc命令: A/***/ B/** C∥ D/*,*/ 52.下面语句运行的结果是什么? System. out printIn (4 3): D.7 53.下列语句中那些是合法的? A String a=abcdefg A-=C BString A="abcdefg C Integer J=new Integer(27) D Integer J=new Integer(27 54.若a和b均是整型变量并已正确赋值,正确的 switch语句是() A switch(a+b) switch( a+b*3.0) C. switch a D switch b 二、多选题(54道) 1.下面代码输出的结果是 public class My For public static void main(String argv int int outer: for(=1; I <3: i++)
哪些行会导致错误? A line 1 B line 2 C line 5 D line 8 50. 如果给出下面列声明: String s1 = new String("Hello"); String s2 = new String("there"); String s3 = new String(); 下面的操作哪些是有效的? A. s3=s1 + s2; B. s3=s1-s2; C. s3=s1 & s2; D. s3=s1 && s2 51. 下面哪种注释方法能够支持 javadoc 命令: A /**...**/ B /*...*/ C // D /**...*/ 52. 下面语句运行的结果是什么? System.out.println(4 | 3); A. 6 B. 0 C. 1 D. 7 53. 下列语句中那些是合法的? A.String A="abcdefg"; A-="cde"; B.String A="abcdefg"; A+="cde"; C.Integer J=new Integer(27); J-=7; D.Integer J=new Integer(27); J--; 54. 若 a 和 b 均是整型变量并已正确赋值,正确的 switch 语句是( )。 A. switch(a+b); { ...... } B. switch( a+b*3.0 ) { ...... } C. switch a { ...... } D. switch ( a%b ) { ...... } 二、 多选题(54 道) 1. 下面代码输出的结果是? public class MyFor{ public static void main(String argv[]){ int i; int j; outer:for (i=1;i <3;i++)
inner: for(=1: j<3: j++)( continue outer: System. out. printin( Value for i="+i+Value for j="+D) a Value for i=1 value for j=1 B Value for i=2 value for j=1 c Value for i=2 value for j=2 d Value for i=3 value for j=1 2.x为什么样的值"Test"可以被打印? switch(x)( case 1 System.out. println("Test1") case 2. ystem out printIn( Test2") break System. out printIn(Test3 BcDE 3 3.那些方法可以插入到程序中注释片段位置? class Baset oublic void amethod(int] public class Scope extends Base( public static void main(string argVU0 ∥ Method Here(选择项插入位置) a void amethod(int i) throws EXception t B void amethod(long throws Exception t c void amethod(long i)t d public void amethod(int i) throws Exception t 4.下面哪个语句正确地声明一个整型的二维数组? A int and= new intlo B int a[10[10]= new intIl C int and= new int[10[10] D int [la= new int[10[10: E int [al= new int[ 10[1 5.在下面代码中那些修饰符可以放在XX位置 public class My Class1 public static void main(String argvI) /修饰符位置XX' class MyInner
inner: for(j=1; j<3; j++) { if (j==2) continue outer; System.out.println("Value for i=" + i + " Value for j=" +j); } } } A Value for i=1 value for j=1 B Value for i=2 value for j=1 C Value for i=2 value for j=2 D Value for i=3 value for j=1 2. x为什么样的值"Test2"可以被打印? switch (x) { case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break; } System.out.println("Test3"); A. 0 B. 1 C. 2 D. 3 E. 4 3. 那些方法可以插入到程序中注释片段位置? class Base{ public void amethod(int i) { } } public class Scope extends Base{ public static void main(String argv[]){} //Method Here(选择项插入位置) } A void amethod(int i) throws Exception {} B void amethod(long i)throws Exception {} C void amethod(long i){} D public void amethod(int i) throws Exception {} 4. 下面哪个语句正确地声明一个整型的二维数组? A int a[][] = new int[][]; B int a[10][10] = new int[][]; C int a[][] = new int[10][10]; D int [][]a = new int[10][10]; E int []a[] = new int[10][10]; 5. 在下面代码中那些修饰符可以放在XX位置 public class MyClass1 { public static void main(String argv[]){ } /*修饰符位置 XX */ class MyInner {} }
A public B private C static d friend 6.接口A的定义如下,指出下列哪些类实现了该接口? int method1(int i) int method2(int A class B implements A t int method10 int method20( Bclass B t int method 1 (int i(I int method2(int D(I C. class B implements A t int method1(int i) nt method2(int DI D. class b extends a int method 1 (int i(] int method2(int D(] E class B implements A t nt method2(int D[] int method 1 (int i1 7.根据程序代码选择所有返回为true的表达式 public static void main(String args[M Float f=new Float(4.2f) Double(4.2) float fl=4,2f: c=; a fequls B C= C D Cequls(t) 8.在一个应用程序中有如下定义:inta={123456,7,89,10}为了打印输出数组a的最 后一个元素,下面不正确的代码是() A System. out. printIn(alloY B. System. out. printIn(a[9D C. System. out. printIn(a(a length) D. System. out. printIn(a(8) 9.下列各种java中的赋值操作语句,哪些在java语言中是正确的赋值语句? A. int A=1 byte B=(byte) B int A=1 char b=a. int A=1. float B=A: D. int A=1: long B=A
A public B private C static D friend 6. 接口A的定义如下,指出下列哪些类实现了该接口? interface A { int method1(int i); int method2(int j); } A .class B implements A { int method1() { } int method2() { } } B .class B { int method1(int i) { } int method2(int j) { } } C .class B implements A { int method1(int i) { } int method2(int j) { } } D .class B extends A { int method1(int i) { } int method2(int j) { } } E .class B implements A { int method2(int j) { } int method1(int i) { } } 7. 根据程序代码选择所有返回为true的表达式 public static void main(String args[]){ Float f=new Float(4.2f); Float c; Double d=new Double(4.2); float fl=4.2f; c=f; } A f.equls(d) B c==f C c==d D c.equls(f) 8. 在一个应用程序中有如下定义:int a[]={1,2,3,4,5,6,7,8,9,10};,为了打印输出数组a的最 后一个元素,下面不正确的代码是( )。 A. System.out.println(a[10]); B. System.out.println(a[9]); C. System.out.println(a[a.length]); D. System.out.println(a(8)); 9. 下列各种java中的赋值操作语句,哪些在java语言中是正确的赋值语句? A. int A =1; byte B=(byte)A; B. int A =1; char B=A; C. int A =1; float B=A; D. int A=1; long B=A;