智慧树知道Java程序设计-智慧树-知到-题库零氪试题及答案

日期:2023-03-26 10:04:14

第一章测试

1、编译和运行以下代码的结果为: public class MyMain{ public static void main(String argv){ System.out.println("Hello cruel world"); } }
    A、编译错误
    B、运行输出 'Hello cruel world'
    C、编译无错,但运行时指示没有定义构造方法
    D、编译无错,但运行时指示找不到main方法

2、以下哪个是Java应用程序入口的main方法头?
    A、public static int main(char args[])
    B、public static void main(String a[])
    C、public static void MAIN(String args[])
    D、public static void main(String argv)

3、编译Java源程序文件将产生相应的字节码文件,字节码文件的扩展名为?
    A、java
    B、class
    C、html
    D、exe

4、main方法是Java  Application程序执行的入口点,关于main方法的方法头合法的有?
    A、public static void main()
    B、public static void main(String[ ] args)
    C、public static int main(String[ ] arg)
    D、public static void main(String arg[ ])

5、每个源程序文件中只能定义一个类。

第二章测试

1、在Java中,十进制数16的十六进制表示格式是?
    A、0x10
    B、0x16
    C、0xA
    D、016

2、要产生[10,100]之间的随机整数使用哪个表达式?
    A、(int)(Math.random()*100)
    B、10+(int)(Math.random()*91)
    C、10+(int)Math.random()*90
    D、10+(int)Math.random()*91

3、下列符号中不能作为Java标识符的是?
    A、abc
    B、$str1
    C、_pore
    D、45six

4、下面各项中定义变量及赋值不正确的是?
    A、int i = 32;
    B、float f = 45.0;
    C、double d = 45.0;
    D、char c = 65;

5、执行以下代码段后, x, a,和 b的值为?  1. int x, a = 6, b = 7;  2. x = a++ + b++;
    A、x= 15, a=7, b=8
    B、x= 15, a=6, b=7
    C、x= 13, a=7, b=8
    D、x= 13, a=6, b=7

6、下列哪个不是Java的保留字?
    A、class
    B、extends
    C、float
    D、cin

7、哪些赋值是合法的?
    A、long test = 012;
    B、float f = -412;
    C、int other = (int)true;
    D、double d = 0x12345678;

8、下列代码中,将引入编译错误的行是 1 public class Exercise{ 2 public static void main(String args[]){ 3 float f = 0.0 ; 4 f = f + 1.0 ; 5 } 6 }
    A、第2行
    B、第3行
    C、第4行
    D、第6行

9、下列哪些是合法标识符?
    A、$persons
    B、TwoUsers
    C、*point
    D、this

10、下列哪些是java中有效的整数表示形式?
    A、22
    B、022
    C、0x22
    D、22H

第三章测试

1、如何更改break语句使退出inner和middle循环,继续外循环的下一轮? outer: for (int x = 0; x < 3; x++) { middle: for (int y = 0; y < 3; y++) { inner: for (int z = 0; z < 3; z++) { if (arr(x, y, z) == targetValue) break; } } }
    A、break inner;
    B、break middle;
    C、break outer;
    D、continue;

2、以下程序的输出结果为? public class Test { public static void main(String args[]) { for ( int k = 0; k < 3; k++) System.out.print("k"); } }
    A、012
    B、k
    C、0123
    D、kkk

3、以下代码的调试结果为? 1: public class Q10 2: { 3: public static void main(String[] args) 4: { 5: int i = 10; 6: int j = 10; 7: boolean b = false; 8: 9: if( b = i == j) 10: System.out.println("True"); 11: else 12: System.out.println("False"); 13: } 14: }
    A、在第9行出现编译错误
    B、在第9行出现运行异常
    C、输出 :True
    D、输出 :False

4、以下代码的调试结果为?以下程序的运行结果为 public class test { public static void main(String args[]) { int i = 1; do { i--; } while (i > 2); System.out.println(i); } }
    A、0
    B、1
    C、2
    D、-1

5、下面的代码段执行之后count的值是什么? int count = 0; for (int i = 1; i < 4; i++) { count += i; } System.out.println(count);
    A、4
    B、1
    C、6
    D、10

6、以下程序的运行结果为: 1. public class Conditional { 2. public static void main(String args [] ) { 3. int x = 4; 4. System.out.println( "value is " + 5. ((x > 4) ? 99.99 : 9)); 6. } 7. }
    A、输出:value is 99.99
    B、输出: value is 9
    C、输出: value is 9.0
    D、在第5行出现编译错误

7、下列程序的运行结果? public class Test { public static void main(String a[]) { int x=3,y=4,z=5; if (x>3) { if (y<2) System.out.println("show one"); else System.out.println("show two"); } else { if (z>4) System.out.println("show three"); else System.out.println("show four"); } } }
    A、show one
    B、show two
    C、show three
    D、show four

8、以下程序调试结果 public class test { public static void main(String args[]) { int i=1, j=3; while (j>0) { j--; i++; } System.out.println(i); } }
    A、4
    B、2
    C、3
    D、0

9、在switch(expression)语句中,expression的数据类型不能是?
    A、double
    B、char
    C、byte
    D、boolean

10、假设a是int类型变量,并初始化为1,则下列哪个为合法的条件语句?
    A、if (a) { }
    B、if (a<3) { }
    C、if (a=2) { }
    D、if (true) { }

第四章测试

1、以下程序运行时输入: java Cycle hello two me 2 public class Cycle{ public static void main(String args[]){ System.out.println(args[1]); } } 则运行结果为?
    A、me
    B、hello
    C、two
    D、2

2、public class test {   public static void main(String args[]) { int m=0; for ( int k=0;k<2;k++)  method(m++); System.out.println(m);  }  public static void method(int m) {    System.out.print(m);  } }
    A、000
    B、012
    C、123
    D、111

3、以下程序运行结果为: public class Q { public static void main(String argv[]) {    int anar[]= new int[5];    System.out.println(anar[0]);  } }
    A、出错: anar在未初始化前被引用
    B、"null"
    C、0
    D、5

4、下列程序的运行结果是: public class Test { public static void main(String args[]) { int m[]={1,2,3,4,5,6,7,8}; int sum = 0; for (int i=0;i<8;i++){ sum = sum + m[i]; if (i==3) break; } System.out.println(sum); } }
    A、3
    B、6
    C、36
    D、10

5、下面定义和给数组初始化正确的是:
    A、String temp [] = new String {''j'' ''a'' ''z''};
    B、String temp [] = { 'j ', ' b' ,'c'};
    C、String temp = {''a'', ''b'', ''c''};
    D、String temp [] = {''a'', ''b'', ''c''};

6、在注释//Start For loop 处要插入哪段代码可以实现 根据变量i的值定位访问数组ia[]的所有元素。 public class Lin{ public void amethod(){ int ia[] = new int[4]; //Start For loop { ia[i]=i; System.out.println(ia[i]); } } }
    A、for (int i=0; i < ia.length() -1; i++)
    B、for (int i=0; i< ia.length(); i++)
    C、for (int i=0; i< ia.length-1; i++)
    D、for (int i=0; i< ia.length;i++)

7、设有如下程序,其调试结果为: class Q2 { public static void main(String[] args) { int[] seeds = {1,2,3,4,6,8}; int n= seeds.length; for (int i = 0; i < 3; i++) for (int k = 0; k< n-1; k++) seeds[k]= seeds[k+1]; for (int i = 0; i     A、输出: 1 2 3 4 6 8
    B、输出: 4 6 8 8 8 8
    C、输出: 2 3 4 6 8 8
    D、输出: 2 3 4 6 6 8

8、下列选项能正确定义一个整形数组的是:
    A、int scores[];
    B、int[] scores;
    C、int scores={0,0,0,0};
    D、int scores=new int[10];

9、设有如下代码: int[] x = new int[25]; 执行后,以下哪个说法正确?
    A、x[24] 为 0
    B、x[25] 为 0.
    C、x[0] 为null.
    D、x.length 为 25.

第五章测试

1、关于以下程序的说明,正确的是( ) 1. class StaticStuff 2. { 3. static int x=10; 4. static { x+=5;} 5. public static void main(String args[ ]) 6. { 7. System.out.println("x=" + x); 8. } 9. static { x/=3;} 10. }
    A、4行与9行不能通过编译,因为缺少方法名和返回类型
    B、9行不能通过编译,因为只能有一个静态初始化器
    C、编译通过,执行结果为:x=5
    D、编译通过,执行结果为:x=3

2、以下程序编译和运行会发生什么 public class Q8 { int i = 20; static { int i = 10; } public static void main(String[] args) { Q8 a = new Q8(); System.out.println(a.i); } }
    A、编译错误,变量 'i' 定义2次.
    B、编译错误,静态初始化只能用于初始化目的
    C、输出 10.
    D、输出 20.

3、给出如下类定义:  public class test {      test(int k) { }  } 如果要创建一个该类的对象,正确的语句是:
    A、test obj1 = new test();
    B、test obj1 = new test(5);
    C、test obj1 = new test('5 ');
    D、test obj1 = new test(3.4);

4、有如下代码: public class Person { … }  下列哪个符合该类的构造方法定义
    A、public void Person() {…}
    B、public static void Person() {…}
    C、public Person() {…}
    D、public int Person() {…}

5、以下代码的输出结果? public class Test{ static int x=5; public static void main(String argv[]){ change(x); x++; System.out.println(x); } static void change(int m){ m+=2; } }
    A、7
    B、6
    C、5
    D、8

6、设有如下程序: public class Test5 { public static void main (String args []) { /* This is the start of a comment if (true) { Test5 = new test5(); System.out.println("Done the test"); } /* This is another comment */ System.out.println ("The end"); } } 结果为?
    A、输出 "Done the test".
    B、程序输出"The end"
    C、程序编译错误.
    D、程序输出"Done the test"和 "The end"

7、给出下面的不完整的类代码: class Person {   String name, department;   int age;   public Person(String n){ name = n; }    public Person(String n, int a){ name = n; age = a; }   public Person(String n, String d, int a) {     // doing the same as two arguments version of constructor    // including assignment name=n,age=a    department = d; } } 下面的哪些表达式可以加到构造方法中的"doing the same as..."处?
    A、Person(n,a);
    B、name=n;age=a;
    C、this(n,a);
    D、this(name,age);

8、考虑如下类: public class Test { int j,k; public Test(int j ) { this(j,0); } public Test(int j, int k) { this.j=j; this.k=k; } } 以下哪些可正确创建Test对象?
    A、Test t = new Test();
    B、Test t = new Test(l);
    C、Test t = new Test(l, 2);
    D、Test t = new Test(l, 2, 3);

第六章测试

1、在Java中,如下的修饰符不是访问控制修饰符
    A、static
    B、public
    C、protected
    D、private

2、类Test1定义如下: 1.public class Test1{ 2. public float aMethod(float a,float b){ } 3. 4.} 将以下哪种方法插入行3是不合法的。
    A、public float aMethod(float a, float b,float c){ }
    B、public float aMethod(float c,float d){ }
    C、public int aMethod(int a, int b){ }
    D、private float aMethod(int a,int b,int c){ }

3、以下代码调试结果 class Base {} class Sub extends Base {} public class CEx{ public static void main(String argv[]){ Base b = new Base(); Sub s = (Sub) b; } }
    A、调试通过
    B、编译异常
    C、运行异常
    D、运行没输出

4、如何定义一个不能有子类的类Key?
    A、class Key { }
    B、abstract final class Key { }
    C、final class Key { }
    D、native class Key { }

5、class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } } 在 // point x安排哪个语句合法?
    A、i = m;
    B、i = b;
    C、i = p.a;
    D、i = p.change(30);

6、如何能使程序调用Base类的构造方法输出"base constructor"; class Base{ Base(int i){ System.out.println("base constructor"); } Base(){ } } public class Sup extends Base{ public static void main(String argv[]){ Sup s= new Sup(); //One } Sup() { //Two } public void derived() { //Three } }
    A、在//One行之后放置Base(10);
    B、在//One行之后放置super(10);
    C、在//Two行之后放置super(10);
    D、在//Three行之后放置super(10);

7、以下程序的输出为? 1: class MyClass 2: { 3: static int maxElements; 4: 5: MyClass(int maxElements) 6: { 7: this.maxElements = maxElements; 8: } 9: 10: } 11: 12: public class Q19 13: { 14: public static void main(String[] args) 15: { 16: 17: MyClass a = new MyClass(100); 18: MyClass b = new MyClass(100); 19: 20: if(a.equals(b)) 21: System.out.println("Objects have the same values"); 22: else 23: System.out.println("Objects have different values"); 24: } 25: }
    A、在第20行出错. equals()方法未定义.
    B、编译通过,在运行时20行出现异常
    C、输出 "Objects have the same values".
    D、输出 "Objects have different values"

8、在构造方法的哪个地方可以调用父类的构造方法?
    A、任何地方
    B、构造方法的第一条语句
    C、构造方法的最后一条语句
    D、不能在构造方法中调用super

9、定义常量时使用的关键字是
    A、static
    B、final
    C、abstract
    D、const

10、设有如下代码: class Base{} public class MyCast extends Base{ static boolean b1=false; static int i = -1; static double d = 10.1; public static void main(String argv[]){ MyCast m = new MyCast(); Base b = new Base(); //Here } } 则在 //Here处插入哪个代码将不出现编译和运行错误。
    A、b=m;
    B、m=b;
    C、d =i;
    D、b1 =i;

第七章测试

1、测试如下代码: public class Ref{ public static void main(String[] args) { StringBuffer sbl = new StringBuffer("Hello"); StringBuffer sb2 = new StringBuffer("Hello"); boolean result = sbl.equals(sb2); System.out.println(result); } } 下述哪条语句正确描述了程序编译和运行的行为?
    A、编译成功,输出为 true
    B、编译成功,输出为 1
    C、编译成功,输出为 false
    D、编译成功,输出为 0

2、String alphabet="ABCDEFGHIJKLMNOPQ" 调用alphabet.substring(6,10)返回什么子字符串?
    A、CDEF
    B、EFGH
    C、FGHI
    D、GHIJ

3、以下程序的调试结果为? 1. public class EqualsTest{ 2. public static void main(String args[]){ 3. Long LA = new Long(7); 4. Long LB = new Long(7); 5. if(LA==LB) System.out.println("Equal"); 6. else System.out.println("Not Equal"); 7. } 8. }
    A、程序在执行到第5行时出现异常
    B、输出"Not Equal"
    C、输出"Equal"
    D、编译错误

4、有如下代码: public class Test{ public static void main(String args[]) { String str = new String("World"); char ch[] = {'H','e','l','l','o'}; change(str,ch); System.out.println(str + "and" + ch); } public static void change(String str, char ch[]) { str = "Changed"; ch[0] = 'C'; } } 运行后输出的结果是:
    A、World and Hello
    B、World and Cello
    C、World and CelloChanged and Hello
    D、Changed and Cello

5、已知代码:  String s = "story";下列语句中合法的是:
    A、s += "books";
    B、char c = s[1];
    C、int len = s.length;
    D、String t = s.toLowerCase();

第八章测试

1、以下程序的编译和运行结果为? abstract class Base{ abstract public void myfunc(); public void another(){ System.out.println("Another method"); } } public class Abs extends Base{ public static void main(String argv[]){ Abs a = new Abs(); a.amethod(); } public void myfunc(){ System.out.println("My Func"); } public void amethod(){ myfunc(); } }
    A、输出结果为 My Func
    B、编译指示 Base 类中无抽象方法
    C、编译通过,但运行时指示Base 类中无抽象方法
    D、编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法

2、以下代码的调试结果为? abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase{ public static void main(String argv[]){ int[] ar = new int[5]; for(i = 0;i < ar.length;i++) System.out.println(ar[i]); } }
    A、输出5个0
    B、错误:ar 未初始化就使用
    C、错误:Mine 必须定义为抽象的
    D、错误,i超出数组下标范围

3、有关内嵌类以下哪个叙述为假?
    A、内嵌类可以访问外部类的成员
    B、方法中的内嵌类可以访问方法中定义的常量
    C、匿名内嵌类没有对应的字节码文件
    D、内嵌类可以被定义为静态成员

4、以下哪个正确定义抽象类?
    A、class Animal { abstract void growl(); }
    B、abstract Animal {abstract void growl();}
    C、class abstract Animal {abstract void growl();}
    D、abstract class Animal {abstract void growl();}

5、考虑如下代码,其中包括一个内嵌类: public final class Test4 { class Inner { void test() { if (Test4.this.flag) { sample(); } } } private boolean flag = false; public void sample() { System.out.println("Sample"); } public Test4() { (new Inner()).test(); } public static void main(String args []) { new Test4(); } } 结果为?
    A、输出 "Sample"
    B、程序无输出,但正确终止
    C、程序不能终止
    D、程序编译失败

6、有关抽象类,以下哪点为真?
    A、不能派生子类
    B、不能对该类实例化
    C、所有方法均为抽象方法
    D、类定义包含abstract 关键字

7、设有类定义如下: class InOut{ String s= new String("Between"); public void amethod(final int iArgs){ int iam=5; iam++; class Bicycle{ public void sayHello(){ //Here } } } public void another(){ int iOther; } } 以下哪些语句可以安排在//Here处 ?
    A、System.out.println(s);
    B、System.out.println(iOther);
    C、System.out.println(iam);
    D、System.out.println(iArgs);

8、在抽象类中,抽象方法定义正确的是?
    A、public abstract method();
    B、public abstract void method();
    C、abstract void Method();
    D、public abstract void method() {}

9、设有如下代码: interface IFace{ } class CFace implements IFace{ } class Base{ } public class ObRef extends Base{ public static void main(String argv[]){ ObRef obj = new ObRef(); Base b = new Base(); Object obj1 = new Object(); IFace obj2 = new CFace(); //Here } } 则在 //Here处插入哪个代码将不出现编译和运行错误。
    A、obj1=obj2;
    B、b=obj;
    C、obj=b;
    D、obj1=b;

10、下列说法正确的是?
    A、java中的子类只允许有一个父类
    B、子类继承了父类的所有方法(包括构造方法)
    C、一个类可以根据需要实现多个接口
    D、一个类定义时没指定父类,则继承Object类。

第九章测试

1、自定义异常的父类是?
    A、Error
    B、VirtualMachineError
    C、Exception
    D、Thread

2、在命令行输入如下命令,结果为 java myprog good morning public class myprog{ public static void main(String argv[]) { System.out.println(argv[2]); } }
    A、myprog
    B、good
    C、morning
    D、出现异常 "java.lang.ArrayIndexOutOfBoundsException: 2"

3、假设m()方法声明抛出IO异常,哪个书写合法.
    A、void m() throws IOException{}
    B、void m() throw IOException{}
    C、void m(void) throws IOException{}
    D、void m() {} throws IOException

4、下列关键字中用于明确抛出一个异常的是?
    A、try
    B、catch
    C、throw
    D、finally

5、检查下面的代码: class E1 extends Exception{} class E2 extends E1{} public class Quiz6_l{ public static void f(boolean flag) throws E1,E2{ if(flag) { throw new E1(); } else { throw new E2(); } } public static void main(String[] args) { try{ f(true); } catch(E2 e2) { System.out.println("Caught E2"); }catch(E1 e1) { System.out.println("Caught El"); } } } 对上面的程序进行编译、运行,下面的叙述哪个是正确的:
    A、由于Qoiz6_1.main方法中没有声明抛出异常E1、E2,所以编译会失败
    B、由于针对E2的catch程序块是无法执行到的,所以编译会失败
    C、编译成功,输出为: Caught El Caught E2
    D、编译成功,输出为: Caught E1

6、设有如下代码段 1 String s = null; 2 if ( s != null & s.length() > 0) 3 System.out.println("s != null & s.length() > 0"); 4 if ( s != null && s.length() > 0) 5 System.out.println("s != null & s.length() > 0"); 6 if ( s != null || s.length() > 0) 7 System.out.println("s != null & s.length() > 0"); 8 if ( s != null | s.length() > 0) 9 System.out.println("s != null | s.length() > 0"); 哪些行将抛出空指针异常?
    A、2,4
    B、6,8
    C、2,4,6,8
    D、2,6,8

7、当2个实际参数分别为4和0时,以下方法调用的执行结果为: public void divide(int a, int b) { try { int c = a / b; } catch (Exception e) { System.out.print("Exception "); } finally { System.out.println("Finally"); } }
    A、输出 Exception Finally
    B、输出 Finally
    C、输出 Exception
    D、无输出

8、检查下面的代码: class E1 extends Exception{ } class E2 extends E1 { } public class Quiz6_5{ public static void main(String[] args){ try{ throw new E1(); } // --X-- } } 下列语句,哪一个可以放到--X--位置,而且保证编译成功。
    A、catch(Exception x){}
    B、catch(final Exceptionx){ }
    C、catch(El x){}
    D、catch(E2 x){}

9、检查下面的代码: class E1 extends Exception{ }; class E2 extends E1{ } class SuperQuiz6_2 { } public class Quiz6_3 extends SuperQuiz6_2{ public void f(Boolean flag) throws E1{ //一一X一一 } } 下列的语句,哪—个可以放到--X--位置,而且保证编译成功。
    A、throw new Exception();
    B、throw new El();
    C、throw new E2();
    D、throw new object();

10、以下叙述那个正确?
    A、一个try 块可跟任意个finally块.
    B、每个try 块必须至少跟一个catch块.
    C、一个try块必须至少跟一个finally 或 catch块.
    D、如果catch 和 finally块均有,则catch 必须先于finally.

第十章测试

1、在Applet的方法中,下列哪个方法将在关闭浏览器时执行,以释放Applet占用的资源?
    A、init()
    B、start()
    C、stop()
    D、destroy()

2、关于以下代码所画图形的说明,正确的是? 1.g.setColor(Color.black); 2.g.drawLine(10,10,10,50); 3.g.setColor(Color.red); 4.g.drawRect(100,100,150,150);
    A、一条40像素长的垂直红线,一个边长为150像素的红色正方形
    B、一条40像素长的垂直黑线,一个边长为150像素的红色正方形
    C、一条50像素长的垂直黑线,一个边长为150像素的红色正方形
    D、一条50像素长的垂直红线,一个边长为150像素的红色正方形

3、paint()方法使用哪种类型的参数?
    A、Graphics
    B、Graphics2D
    C、String
    D、Color

4、下列Applet类的方法中,在Applet的整个生命周期里至多只能执行一次的是?
    A、init();
    B、start();
    C、stop();
    D、repaint();

5、为了向一个Applet传递参数,可以在HTML文件的APPLET标签中使用PARAM选项,在Applet程序中获取参数时,应使用的方法是
    A、getParameter()
    B、getDocumentBase()
    C、getCodeBase()
    D、getImage()

第十一章测试

1、下列哪个容器类使用时必须加入到其他的容器中?
    A、Window
    B、Frame
    C、Dialog
    D、Panel

2、在AWT中部件如何注册事件监听者?
    A、调用应用的addXXXListener()方法
    B、调用事件addXXXListener()方法
    C、调用部件的addXXXListener()方法
    D、调用监听者的addXXXListener()方法

3、通过哪个方法可以改变按钮的颜色?
    A、setColor
    B、setBackground
    C、getBackground
    D、setForeground

4、新创建的 Frame是不可见的,使用哪个方法可使其可见
    A、setSize(300,200)
    B、setVisible(true)
    C、dispose()
    D、repaint()

5、Frame的默认的布局管理器是下列哪一个
    A、FlowLayout
    B、BorderLayout
    C、GridLayout
    D、CardLayout

6、有关事件监听者以下哪个为真?
    A、一个部件可有多个监听者
    B、一个部件只能有一有监听者
    C、一个监听者可处理来自多个部件的事件.
    D、一个监听者只能处理来自一个部件的事件.

7、哪个方法可得到WindowEvent中的事件源?
    A、getFrame()
    B、getWindow()
    C、getSource()
    D、getID()

第十二章测试

1、哪个关键字用于与锁标记打交道?
    A、native
    B、static
    C、synchronized
    D、abstract

2、线程在生命周期要经历5种状态,如果线程当前是新建状态,则它可到达的下一个状态是?
    A、运行状态
    B、阻塞状态
    C、可运行状态
    D、终止状态

3、以下哪个方法用来定义线程的执行体?
    A、start()
    B、init()
    C、run() run()
    D、main()

4、下面说法不正确的是( )
    A、Java中线程是抢占式的 
    B、Java中线程是分时的
    C、Java中的线程可以共享数据
    D、Java中的线程可以共享代码

5、下列程序的功能是在监控台上每一秒种显示一个字符串“Hello!”,能够填写在线程中下划线位置,使程序完整并能正确运行的语句是 public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try { ________; } catch(________e){ } System.out.println(“Hello”); } } }
    A、sleep(1000) InterrutpedException
    B、t.sleep(1000) InterruptedException
    C、Thread.sleep(1000) RuntimeException
    D、Thread.sleep(1000) InterruptedException

第十三章测试

1、用DataOuputStream的哪个方法写一个字符串到顺序文件?
    A、writeInt
    B、writeString
    C、writeSTR
    D、writeUTF

2、在读文件employ.dat时,使用该文件名作为字符串参数的类是?
    A、BufferedReader
    B、DataInputStream
    C、DataOutputStream
    D、FileInputStream

3、给一个已存在的文件用FileWriter("report")给其写入数据,则结果为?
    A、数据添加到文件中;
    B、文件内容被新内容替换;
    C、由于文件已存在,将抛出异常;
    D、数据写入到文件的随机位置。

4、以下哪个是构造RandomAccessFile的合法方式?
    A、RandomAccessFile("data", "r");
    B、RandomAccessFile("r", "data");
    C、RandomAccessFile("data", "read");
    D、RandomAccessFile("read", "data");

5、在File类提供的方法中,用于创建目录的方法是?
    A、mkdir()
    B、mkdirs()
    C、list()
    D、listFiles()

第十四章测试

1、关于泛型,以下哪个叙述为假?
    A、泛型的类型参数允许基本类型
    B、泛型的本质是参数化类型
    C、JDK1.4版本不支持泛型
    D、泛型参数定义时允许使用extends子句进行限定

2、关于java.util.Collections类的叙述,以下哪个为真?
    A、Collections类实现Collection接口;
    B、Collections类提供有sort方法可用于对集合的排序;
    C、Collections类提供有sort方法用于对列表的排序;
    D、Collections类的addALL方法每次只能加1个数据到集合中。

3、欲构造ArrayList类的一个实例,元素类型为String,作为List类型的对象,下列哪个方法是正确的 ?
    A、ArrayList myList=new Object();
    B、List myList=new ArrayList ();
    C、ArrayList myList=new List ();
    D、List myList=new List ();



4、类 java.util.HashMap 实现的接口是?
    A、java.util.Map
    B、java.util.List
    C、java.util.Set
    D、java.util.Collection



5、设有泛型类的定义如下 class Test { } 则由该类创建对象时,使用正确的是?
    A、Test x = new Test(); 数据添加到文件中;
    B、Test x = new Test ();
    C、Test x = new Test();
    D、Test x = new Test ();



第十五章测试

1、类JOptionPane中的哪个方法可以用来读取用户的输入数据
    A、showMessageDialog( )
    B、showInputDialog( )
    C、read()
    D、readLine()



2、哪个方法给JFrame窗体加入菜单条?
    A、setJMenu()
    B、setJMenuBar()
    C、add()
    D、addJMenuBar()



3、JPanel的默认布局管理器是?
    A、BorderLayout
    B、GridLayout
    C、FlowLayout
    D、CardLayout



4、JTextField 的事件监听器接口为?
    A、ItemListener
    B、ActionListener
    C、JActionListener
    D、ChangeListener



5、Swing部件中图形绘制一般是通过重写以下哪个方法?
    A、paint
    B、paintComponent
    C、update
    D、er readLine() paintBorder