[单选题]

( 28 )阅读下面程序

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()

参考答案与解析:

相关试题

阅读下面程序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行“祝

  • 查看答案
  • 阅读下面程序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

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

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

  • 查看答案
  • 阅读下面程序 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

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