单选题:运行下列Java程序, 会产生什么结果
运行下列Java程序, 会产生什么结果
1 public class X extends Thread implements Runnable{
2 public void run(){
3 System.out.println("this is run()");
}
4 public static void main(String args[])
{
5 Thread t=new Thread(new X());
6 t.start();
}
}
A.第一行会产生编译错误
B.第六行会产生编译错误
C.第六行会产生运行错误
D.程序会正常编译和运行,输出:this is run()
答案:D
1 public class X extends Thread implements Runnable{
2 public void run(){
3 System.out.println("this is run()");
}
4 public static void main(String args[])
{
5 Thread t=new Thread(new X());
6 t.start();
}
}
A.第一行会产生编译错误
B.第六行会产生编译错误
C.第六行会产生运行错误
D.程序会正常编译和运行,输出:this is run()
答案:D