单选题:以下Java程序的功能是在监控台上每隔1秒左右显示当前时间,请选择合适的答案填空。
以下Java程序的功能是在监控台上每隔1秒左右显示当前时间,请选择合适的答案填空。
import java.util.Date;
class DisplayTime implements Runnable {
public static void main(String[] args){
DisplayTime t=new DisplayTime();
Thread tt=new Thread(t);
tt.start();
}
public void run(){
for(;;){
try {
____________________;
}catch(InterruptedException e){e.printStackTrace();}
System.out.println(_______________);
}
}
}
A.Thread.sleep(1)<br>
new Date()
B.Thread.sleep(1000)<br>
new Date()
C.Thread.sleep(1)<br>
new Time()
D.Thread.sleep(1000)<br>
new Time()
答案:B
import java.util.Date;
class DisplayTime implements Runnable {
public static void main(String[] args){
DisplayTime t=new DisplayTime();
Thread tt=new Thread(t);
tt.start();
}
public void run(){
for(;;){
try {
____________________;
}catch(InterruptedException e){e.printStackTrace();}
System.out.println(_______________);
}
}
}
A.Thread.sleep(1)<br>
new Date()
B.Thread.sleep(1000)<br>
new Date()
C.Thread.sleep(1)<br>
new Time()
D.Thread.sleep(1000)<br>
new Time()
答案:B