• 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

  • 相关阅读:
    java计算机毕业设计小区车辆管理系统源程序+mysql+系统+lw文档+远程调试
    RabbitMQ与springboot整合
    【C++ 实战】概论 | 代码风格 | 类
    函数指针
    nginx转发https到tomcat报错403
    Qt开发思想探幽]QObject、模板继承和多继承
    嵌入式单元测试工具Tessy的一些测试技巧
    Day84:服务攻防-端口协议&桌面应用&QQ&WPS等RCE&hydra口令猜解&未授权检测
    IOS Swift 从入门到精通:@escaping 和PreferenceKey
    RabbitMQ保证消息的可靠性
  • 原文地址:https://blog.csdn.net/m0_67402341/article/details/125439530