为了使下列程序正常运行并且输出5个数字, 在下划线处应填入的是()class PrintInt ____________ { public void ___________() { for (int i = 0; i < 5; i++) { System.out.print(i + " "); try { Thread.sleep(500); } catch (Exception e) { } } }}public class Test6 { public static void main(String[] args) { Thread p = new PrintInt(); p.start(); }}
A. extends Thread, PrintInt
B. extends Thread, run
C. implements, run
D. extends Thread, init
查看答案
下列方法在被调用后, 不会改变所在线程运行状态的是()
A. stop()
B. yield()
C. sleep()
D. notifyAll()
在下列SynchronizedCounter类的定义中, 为了保证并发操作的正确性, 应在下划线处填入的代码自上而下分别是()public class SynchronizedCounter { private int c = 0; public ___________ void increment() { c++; } public ___________ void decrement() { c--; } public ___________ int value() { return c; }}
A. 都可以不填
B. synchronized, synchronized, 可不填
C. 可不填, 可不填, synchronized
D. synchronized, synchronized, synchronized
Java中, 定义子类继承父类用到的关键字是()
A. extends
B. this
C. inheritance
D. final
定义接口的关键字是()
A. public
B. private
C. interface
D. final