[单选题]

阅读下面程序 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行“祝你成功!”,必须改正程序中的某行代码,选择正确的修改是

A.将第1行的extends Thread改为implements Runnable

B.将第3行的new Try()改为new Thread()

C.将第4行的t.start()改为start(t)

D.将第7行的public void run(int j)改为public void run()

参考答案与解析:

相关试题

阅读下面程序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行“祝你成功!”,必须改正程

  • 查看答案
  • 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行“祝

  • 查看答案
  • 阅读下面程序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行“祝你成功!”,必须改正程

  • 查看答案
  • ( 28 )阅读下面程序1 public class Try extends T

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

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

    [单选题]阅读下列程序: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.该程序能够通过编译,但运行时将不调用Thr

  • 查看答案
  • 阅读下面程序public void test() { try{ sayHello

    [单选题]阅读下面程序 public void test() { try{ sayHello(); System.out.println("hello"); } catch(ArrayIndexOutOfBoundException e) { System.out.println("ArrayIndexOutOfBoundException"); } catch(Exception e) { System.out.println("Exception"); } finally { System

  • 查看答案
  • 阅读下面程序 public class Test1 {public static

    [单选题]阅读下面程序 public class Test1 { public static void main(String[] args){ System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行结果是A.84 49 6 2B.90 25 6 2.5C.84 23 12 2D.68 49 14 2.5

  • 查看答案
  • 阅读下面程序public class Test1 {public static

    [单选题]阅读下面程序 public class Test1 { public static void main(String[] args) { System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行的结果是A.84 49 6 2B.90 25 6 2.5C.84 23 12 2D.68 49 14 2.5

  • 查看答案
  • 阅读下面程序 public class Test1 {public static

    [单选题]阅读下面程序 public class Test1 { public static void main(String[] args){ System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行结果是A.84 49 6 2B.90 25 6 2.5C.84 23 12 2D.68 49 14 2.5

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