问题 单项选择题

下列程序的功能是在监控台上每隔一秒钟显示一个字符串"Hello",能够填写在程序中横线位置,使程序完整并能正确运行的语句是( )。 public class Test implements Runnable {public static void main (String[ ] args ) { Test t =new Test( ); Thread tt= new Thread(t); tt. start( );public void run ( ) { for(; ; ){try{__________;}catch (__________ e ){}System. out. println (" Hello" );}} }

A.sleep(1000); InterruptedException

B.sleep(1000); InterruptedException

C.Threa sleep(1000); RuntimeException

D.Threa sleep(1000); InterruptedException

答案

参考答案:D

解析: 当清除线程调用因暂停类方法而产生的中断状态时,会发送InterruptedException类异常。

多项选择题 案例分析题
单项选择题 A1/A2型题