下列程序的功能是在监控台上每隔一秒钟显示一个字符串”Hello!”,能够填写在程序中下画线位置,使程序完整并能正确运行的语句是( )。 public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test: Threadt t=new Thread(t); tt.start: } public void run{ for(;;){ try{ ; }catch(e){} System.out.println("Hello"); } } }
A.sleep(1000)
B.t.sleep(1000)InterruptedExceptionInterruptedException
C.Thread.sleep(1000)
D.Thread.sleep(1000)RuntimeExceptionInterruptedException
第1题:
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
A.Test t=new Test();
B.Thread t=new Thread();
C.Thread t=new Thread(new Test());
D.Test t=new Thread();
第2题:
下列程序的功能是在监控台上每隔-秒钟显示-个字符串”Hello!¨,能够填写在程序中下画线位置,使程序完整并能正确运行的语句是( )。
A.sleep(1000)
B.t. sleep(1000) InterruptedExceptionInterruptedException
C.Thread. sleep(1000)
D.Thread. sleep(1000) RuntimeExceptionlnterruptedException
第3题:
下列程序的功能是在监控台上每隔一秒钟显示一个字符串"Hello!",能够填写在程序中下划线位置,使程序完整并能正确运行的语句是
publicclassTestimplementsRunnable{
publicstaticvoidmain(Stringargs[]){
Testt=newTest();
Threadtt=newThread(t);
tt.start();
}
publicvoidrun(){
for(;;){
try{
}catchL______e){}
System.out.println("Hello");
}
}
}
A.
B.
C.
D.
第4题:
下列程序的功能是在监控台上每隔一秒钟显示一个字符串“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)
B.t.sleep(1000)InteruptedException InterruptedException
C.Thread.sleep(1000)
D.Thread.sleep(1000)RuntimeException InterruptedException
第5题:
在下画线处填入代码,使程序正常运行并且输出“Hello!”。
class Test ______ {
public staric void maim (string[] args) {
Test t=new Test();
t.start();
}
public void run() {
System.out.println("Hello!");
}
}
第6题:
下列程序的功能是将一个整数数组写入二进制文件,在程序的下画线处应填人的选项是( )。
A.writeArray
B.writeByte
C.writeInt
D.writeDouble
第7题:
下列程序的功能是创建一个显示5个“Hello!”的线程并启动运行,试将程序补充完整。
public class ThreadTest extends Thread{
public static void main(String args[ ]){
ThreadTest t=new______;
t.start( );}
public void run( ){int i=0;
while(true){System.out.println("Hello!");
if(i++==4)break;
}
}
第8题:
下列程序的功能是在监控台上每隔一秒钟显示一个字符串“你好!”,能够填写在程序中画线位置,使程序完整并能正确运行的语句是 public class Exam implements Runnable{ public static void main(String args[]){ Exam t=new Exam(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try{ ; }catch(e){} System.out.println("你好!"); } } }
A.sleep(1) RuntimeException
B.t.sleep(1000) InterruptedException
C.Thread.sleep(1) InterruptedException
D.Thread.sleep(1000) InterruptedException
第9题:
下列程序的功能是在监控台上每隔一秒钟显示一个字符串"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.t. sleep(1000); InterruptedException
C.Thread. sleep(1000); RuntimeException
D.Thread. sleep(1000); InterruptedException