java进阶题_java进阶复习题.doc

java进阶复习题

Name:_______________________

Covers Chs 29-31Sample Exam

Multiple Choice Questions Only for This Test

Part I: Questions: (1 pts each)

1 You should always invoke the unlock method in the finally clause.

A. true

B. false

2 Given the following code, which set of code can be used to replace the comment so that the program displays time to the console every second?

import java.applet.*;

import java.util.*;

public class Test extends Applet implements Runnable {

public void init() {

Thread t = new Thread(this);

t.start();

}

public void run() {

for(; ;) {

//display time every second

System.out.println(new Date().toString());

}

}

}

A. try { Thread.sleep(1000); } catch(InterruptedException e) { }

B. try { sleep(1000); } catch(InterruptedException e) { }

C. try { Thread.sleep(1000); } catch(RuntimeException e) { }

D. try { t.sleep(1000); } catch(InterruptedException e) { }

3 Which of the following expressions must be true if you create a thread using Thread = new Thread(object)?

A. object instanceof Applet

B. object instanceof Thread

C. object instanceof Frame

D. object instanceof Runnable

4 How do you create a condition on a lock?

A. Condition condition = Lock.getCondition();

B. Condition condition = Lock.newCondition();

C. Condition condition = lock.getCondition();

D. Condition condition = lock.newCondition();

5 Which method on a condition should you invoke to causes the current thread to wait until the condition is signaled?

A. condition.waited();

B. condition.await();

C. condition.waiting();

D. condition.wait();

6 To run an object on a separate thread, the object must be a subclass of Thread.

A. true

B. false

7 The Runnable interface is more general than the Thread class. You can convert any class that extends Thread to a class that implements Runnable.

A. true

B. false

8 An exception occurs if the resume() method is invoked by a finished thread object.

A. true

B. false

9 You can set a priorit

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值