[单选题]

阅读下列代码段

C.lass Test implements Runnable {

Public int run( ) {

Int i = 0;

While (true) {

i++;

System.out.println ( “ i= ” +i);

}

}

}

上述代码的编译结果是

A. )程序通过编译并且 run () 方法可以正常输出递增的 i 值

B. )程序通过编译,调用 run () 方法将不显示任何输出

C. )程序不能通过编译,因为 while 的循环控制条件不能为 “ true ”

D. )程序不能通过编译,因为 run () 方法的返回值类型不是 void

参考答案与解析:

相关试题

阅读下面代码class Test implements Runnable { p

[单选题]阅读下面代码 class Test implements Runnable { public int run() { int i=0; while(true) { i++; System.out.println("i="+i); } } } 上述代码的编译结果是A.程序通过编译,并且run()方法可以正常输出递增的i值B.程序通过编译,调用run()方法将不显示任何输出C.程序不能通过编译,因为while的循环控制条件不能为trueD.程序不能通过编译,因为run()方法的返回值类型不是vo

  • 查看答案
  • 阅读下面程序class Test implements Runnable { p

    [单选题]阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t=new Test(); t.start(): } public void run() {} } 下列关于上述程序的叙述正确的是A.程序不能通过编译,因为start()方法在Test类中没有定义B.程序编译通过,但运行时出错,提示start()方法没有定义C.程序不能通过编译,因为run()方法没有定义方法体D.程序编译通过

  • 查看答案
  • 阅读下面程序class Test implements Runnable{pub

    [单选题]阅读下面程序class Test implements Runnable{public static void main(String[] args){Test t = new Test();t.start();}public void run(){ }}下列关于上述程序的叙述正确的是A.) 程序不能通过编译,因为 start() 方法在 Test 类中没有定义B.) 程序编译通过,但运行时出错,提示 start() 方法没有定义C.) 程序不能通过编译,因为 run() 方法没有定义方法体D.

  • 查看答案
  • 阅读下面程序class Test implements Runnable {pu

    [单选题]阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t = new Test(); t.startO; } public void run(){ } } 下列关于上述程序的叙述正确的是A.程序不能通过编译,因为start()方法在Test类中没有定义B.程序编译通过,但运行时出错,提示start()方法没有定义C.程序不能通过编译,因为run()方法没有定义方法体D.程序编译通

  • 查看答案
  • 阅读下面程序class Test implements Runnable {pu

    [单选题]阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t = new Test(); t.startO; } public void run(){ } } 下列关于上述程序的叙述正确的是A.程序不能通过编译,因为start()方法在Test类中没有定义B.程序编译通过,但运行时出错,提示start()方法没有定义C.程序不能通过编译,因为run()方法没有定义方法体D.程序编译通

  • 查看答案
  • 阅读下列代码public class Test implements Runna

    [单选题]阅读下列代码 public class Test implements Runnable{ public void run(Thread t){ System. out. println("Running. "); } public static void main(String[]args){ Thread tt=new Thread(new Test()); tt. start(); } } 代码运行结果是A.将抛出一个异常B.没有输出并正常结束C.输出“Running”并正常结束D.程

  • 查看答案
  • 阅读下面代码public class Test implements Runna

    [单选题]阅读下面代码 public class Test implements Runnable { public void run(Thread t) { System.out.println("Running"); } public static void main(String[] args) { Thread tt=new Thread(new Test()); tt.start(); } } 代码运行的结果是A.将抛出一个异常B.没有输出并正常结束C.输出“Running”并正常结束D.程

  • 查看答案
  • ( 18 )阅读下列程序Public class Test implements

    [单选题]( 18 )阅读下列程序Public class Test implements Runnable{Private int x=0;Private int y=o;boolean flag=true;Public static void main(string[ ] args) {Test r =new Test( );Thead t1=new Thead(r);Thead t2=new Thead(r);t1.start( );t2.start( );}Public void run(){Wh

  • 查看答案
  • 阅读下面程序public class Test implements Runna

    [单选题]阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是A.Test t=flew Test()B.Thread t=new Th

  • 查看答案
  • 阅读下面程序public class Test implements Runna

    [单选题]阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是A.Test t=new Test();B.Thread t=new Thread();C.Thread t=new Thread(new

  • 查看答案
  • 阅读下列代码段Class Test implements Runnable {P