[单选题]

阅读下列程序: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 test.”

B.该程序能够通过编译,但运行时将不调用ThreadTest类中的run()方法,因此不产生任何输出

C.该程序存在编译错误,因为在main()方法中不能使用this指针

D.上述选项都不正确

参考答案与解析:

相关试题

阅读下面程序1 public class Try extends Thread

[单选题]阅读下面程序 1 public class Try extends Thread { 2 public static void main(String args[]) { 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j) { 8 int i=0; 9 while(i<5) { 10 System.out.println("祝你成功!"); 11 i++: 12 } 13 } 14 } 该程序若能打印5行“祝你成功!”

  • 查看答案
  • 阅读下面程序1public class Try extends Thread{

    [单选题]阅读下面程序 1public class Try extends Thread{ 2public static void main(String args[]){ 3Tryt=new Try(); 4t.start(); 5} 6 7publicvoidrun(intj){ 8inti=0; 9while(i<5){ 10System.out.println("祝你成功!"); 11 i++; 12} 13} 14} 该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。

  • 查看答案
  • 阅读下面程序1public class Try extends Thread{2

    [单选题]阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i=0; 9 while(i<5){ 10 System.out.println(“祝你成功!”); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功!”,必须改正程

  • 查看答案
  • 阅读下面程序1public class Try extends Thread{2

    [单选题]阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i=0; 9 while(i<5){ 10 System.out.println(“祝你成功!”); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功!”,必须改正程

  • 查看答案
  • 3阅读下面程序1public class Try extends Thread{

    [单选题]3阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[ ]){ 3 Try t = new Try( ); 4 t.start( ); 5 } 6 7 public void run( int j){ 8 int i = 0; 9 while(i<5) { 10 System.out.pfintln("祝你成功"); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝

  • 查看答案
  • 下列程序的执行结果是______。class A5 extends Thread

    [单选题]下列程序的执行结果是______。 class A5 extends Thread { boolean b; A5 (boolean bb) { b = bb; } public void run() { System.out.println(this.getName() + "运行"); } } public class Testl5 { public static void main(String[] args) { A5 a1 = new A5(true); A5 a2 = new A

  • 查看答案
  • 阅读下面程序:public class ThreadTest { public

    [单选题]阅读下面程序: public class ThreadTest { public static void main(String args[]) throws Exception { int i=0; Hello t=new Hello(); ______; While(true) } System.out.println("Good Morning"+i++); if(i==2&&t.isAlive()) { System.out.println("Main waitin

  • 查看答案
  • 请阅读下面程序 public class ThreadTest {public

    [单选题]请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) { System. out.println("Main waiting for

  • 查看答案
  • 请阅读下面程序 public class ThreadTest {public

    [单选题]请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) { System. out.println("Main waiting for

  • 查看答案
  • ( 24 )请阅读下面程序public class ThreadTest {pu

    [单选题]( 24 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]){Thread t1 = new Thread ( new Hello ()):Thread t2 = new Thread ( new Hello ()):t l .start ():t2.start ();}}class Hello implements Runnable {int i ;public void run (){while

  • 查看答案
  • 阅读下列程序:class ThreadTest extends Thread{p