单选题
下列程序的运行结果是( )。
publicclassTestextendsThread
publicstaticvoidmain(String[]args)
Threadt=newThread():
A、
start();
publicvoidrun()
System.out.println("Hello");
B、
程序不能通过编译,因为没有import语句将Thread类引入
C、
程序不能通过编译,因为Test类没有实现Runnable接口
D、
程序通过编译,且运行正常,没有任何输出
E、
程序通过编译,且运行正常,打印出一个"Hello"
【正确答案】
D
【答案解析】
start()方法相当于run()方法的入口,调用了start()方法,run()方法执行,D选项正确。
提交答案
关闭