问题
单项选择题
阅读下列程序:class ThreadTest extends Thread{ public static void main(String[]args){ Thread t=new Thread(this); t.start(); } public void run(){ System.out.print("A thread test."); }} 对该程序而言,正确结论是( )
A.该程序能够通过编译并打印输出“A thread tes”
B.该程序能够通过编译,但运行时将不调用ThreadTest类中的run()方法,因此不产生任何输出
C.该程序存在编译错误,因为在main()方法中不能使用this指针
D.上述选项都不正确
答案
参考答案:C
解析: 该题是对this知识点的考查。该程序在编译存在错误,在main()方法中不能使用this。所以选项A、B、C的说法是错误的。