16秋西交《Java语言》在线作业 下载本文

内容发布更新时间 : 2024/5/28 5:52:49星期一 下面是文章的全部内容请认真阅读。

奥鹏17春16秋西交《Java语言》在线作业

一、单选(共 10 道,共 20 分。)

1. 哪个关键字可以对对象加互斥锁?( ) A. transient B. synchronized C. serialize D. static 标准解:

2. 对方法main的第1行定义正确的是( )。。 A. public main( String arg [ ] ) B. public void main( String arg [ ] )

C. public static void main( String arg [ ] ) D. public static void main( String args [ ] ) 标准解:

3. 下列哪些语句关于内存回收的说明是正确的? ( ) A. 程序员必须创建一个线程来释放内存; B. 内存回收程序负责释放无用内存

C. 内存回收程序允许程序员直接释放内存

D. 内存回收程序可以在指定的时间释放内存对象 标准解:

4. 运行下列程序, 会产生什么结果 public class X extends Thread implements

Runable{ public void run(){ System.out.println(\ } public static void main(String args[]) { Thread t=new Thread(new X()); t.start(); } } ( ) A. 第一行会产生编译错误 B. 第六行会产生编译错误 C. 第六行会产生运行错误 D. 程序会运行和启动 标准解:

5. 看以下程序: boolean a=false; boolean b=true; boolean c=(a&&b)&&(!b); int result=c==false?1:2; 这段程序执行完后,c与result的值是:( )。。 A. c=false;result=1; B. c=true;result=2; C. c=true;result=1; D. c=false;result=2; 标准解:

6. 要从文件\文件中读出第10个字节到变量C中,下列哪个方法适合? ( )

A. FileInputStream in=new FileInputStream(\B. FileInputStream in=new FileInputStream(\C. FileInputStream in=new FileInputStream(\

D. RandomAccessFile in=new RandomAccessFile(\标准解:

7. 运行下列程序, 会产生什么结果 ( ) public class X extends Thread implements Runable{ public void run(){ System.out.println(\is run()\ } public

static void main(String args[]) { Thread t=new Thread(new X()); t.start(); } } 。。 A. 第一行会产生编译错误 B. 第六行会产生编译错误 C. 第六行会产生运行错误 D. 程序会运行和启动 标准解:

8. 对于下列代码: public class Parent { public int addValue( int a, int b) { int s; s = a+b; return s; } } class Child extends Parent { } 下述哪些方法可以加入类Child? ( ) A. int addValue( int a, int b ){// do something...}

B. public void addValue (int a, int b ){// do something...} C. public int addValue( int a ){// do something...}

D. public int addValue( int a, int b )throws MyException {//do something...} 标准解:

9. 下列关于Java线程的说法那些是正确的( )

A. 每一个Java线程可以看成由代码、一个真实的CPU以及数据三部份组成。

B. 创建线程的两种方法中,从Thread类中继承的创建方式可以防止出现多父类问题。 C. Thread类属于java.util程序包。 D. 以上说法无一正确。 标准解:

10. 运行下列程序,会产生什么结果() class Outer1{ private int a; void foo(double d,final float f){ String s; final boolean b; class Inner{ void methodInner(){ System.out.println(\the Inner\ } } } public static void main(String args[]) { Outer1 me=new Outer1(); me.foo(123,123); System.out.println(\ } } 。。 A. in the Inner outer B. outer

C. in the Inner D. 编译不通过 标准解:

西交《Java语言》在线作业

二、多选(共 15 道,共 30 分。)

1. 下面哪些语句能够正确地生成5个空字符串? ( )

A. String a [] = new String [5]; for (int i = 0; i < 5; a[i++] = \B. String a [] = {\C. String a [5];

D. String [5] a; E. String [] a = new String [5]; for (int i = 0; i < 5; a[i++] = null); 标准解:

2. 下面的说法正确的是( )。。 A. Java语言里的线程不是对象 B. Applet不需要main方法

C. Java语言的对象都是java.lang.Object的子类 D. double是Java语言的合法标识符 标准解:

3. 选出合理的标识符 ( ) A. _sys1_lll B. 2mail C. $change D. class 标准解:

4. 下面关于Java代码安全的说法哪些是正确的?() 。。

A. 程序执行过程中需要的所有类都是通过字节码校验程序装入的。 B. 代码的运行是由Java运行环境中的解释器完成的。

C. 在运行时,字节码要经过装入,校验之后,才能在解释器中执行。 D. 在缺省的安全配置条件下,Java pplet不能访问任何本地资源。 标准解:

5. 如果下列的方法能够正常运行,在控制台上将显示什么?( ) public void example(){ try{ unsafe(); System.out.println(\ } catch(SafeException e) {System.out.println(\2\ finally{System.out.println(\3\ System.out.println(\ } A. Test 1 B. Test 2 C. Test 3 D. Test 4 标准解:

6. 下列说法正确的是 ( ) A. java.lang.Clonable是类 B. java.lang.Runnable是接口 C. Double对象在java.lang包中 D. Double a=1.0是正确的java语句 标准解: