西交《Java语言》在线习题.docVIP

  • 40
  • 0
  • 约7.13千字
  • 约 7页
  • 2018-11-16 发布于江苏
  • 举报
西交《Java语言》在线习题

谋学网 HYPERLINK 一、单选题(共 10 道试题,共 20 分。)V 1. 哪个关键字可以对对象加互斥锁?( ) A. transient B. synchronized C. serialize D. static 满分:2 分 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 [ ] ) 满分:2 分 3. 下列哪些语句关于内存回收的说明是正确的? ( ) A. 程序员必须创建一个线程来释放内存; B. 内存回收程序负责释放无用内存 C. 内存回收程序允许程序员直接释放内存 D. 内存回收程序可以在指定的时间释放内存对象 满分:2 分 4. 运行下列程序, 会产生什么结果    public class X extends Thread implements Runable{     public void run(){      System.out.println(this is run());     }     public static void main(String args[])     {      Thread t=new Thread(new X());      t.start();     }    } ( ) A. 第一行会产生编译错误 B. 第六行会产生编译错误 C. 第六行会产生运行错误 D. 程序会运行和启动 满分:2 分 5. 看以下程序:   boolean a=false;   boolean b=true;   boolean c=(ab)(!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; 满分:2 分 6. 要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? ( ) A. FileInputStream in=new FileInputStream(file.dat); in.skip(9); int c=in.read(); B. FileInputStream in=new FileInputStream(file.dat); in.skip(10); int c=in.read(); C. FileInputStream in=new FileInputStream(file.dat); int c=in.read(); D. RandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); int c=in.readByte(); 满分:2 分 7. 运行下列程序, 会产生什么结果 ( )  public class X extends Thread implements Runable{   public void run(){    System.out.println(this is run());   }   public static void main(String args[])   {    Thread t=new Thread(new X());    t.start();    }   } 。。 A. 第一行会产生编译错误 B. 第六行会产生编译错误 C. 第六行会产生运行错误 D. 程序会运行和启动 满分:2 分 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

文档评论(0)

1亿VIP精品文档

相关文档