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行“祝你成功”必须改正程序中的某行代码,程序才能完成。选择正确的修改是( )。A.将第1行的extends Thread改为implements RunnableB.将第3行的new Try()改为new Thread()C.将第4行t.sta.rt()改为start(t)D.将第7行的publ void run(int j)改为public void run()

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行“祝你成功”必须改正程序中的某行代码,程序才能完成。选择正确的修改是( )。

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

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

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

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


相关考题:

请阅读下面的程序classTest/{privatestaticStringname;static/{name="World";System.out.print(name);/}publicstaticvoidmain(String[]args)/{System.out.print("Hello");Testtest=newTest();/}/}下列选项中,程序运行结果是()。:A.WorldB.HelloC.World HelloD.Hello World

publicclassAextendsThread{A(){setDaemon(true);}publicvoidrun(){(newB()).start();try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Adone”);}classBextendsThread{publicvoidrun(){try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Bdone”);}}publicstaticvoidmain(String[]args){(newA()).start();}}Whatistheresult?()A.AdoneB.BdoneC.AdoneBdoneD.BdoneAdoneE.Thereisnoexceptionthattheapplicationwillprintanything.F.Theapplicationoutputs“Adone”and“Bdone”,innoguaranteedorder.

阅读下面程序 public class ConcatTest{ public static void main(String[] args) { String strl = "abc"; String str2 = "ABC"; String str3 = str1.concat(str2); System.out.println(str3); } } 程序的运行结果是:A.abeB.ABCC.abcABCD.ABCabc

阅读以下说明和Java代码,将解答写入对应栏内。【说明】下面的程序的功能是利用实现Runnable接口的方法来创建线程,并利用它来执行响应的一些操作。最后使得m的执行结果:100,如图3。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。class ClassName (1) Runnable {int n;(2) {try{Thread. sleep (2000);n=100;}catch( (3) e) {}}public static void main(String[ ]args) {try{ClassName a = new ClassName( );(4)threadl. (5) ();threadl, join( );int m=a.n;System. out. println("m=" + m);}catch( (3) e){}}}

作为Java应用程序入口的main方法,其声明格式可以是( )。A、publicstaticvoidmain(String[]args)B、publicstaticintmain(String[]args)C、publicvoidmain(String[]args)D、publicintmain(String[]args)

●试题七阅读以下说明和Java代码,将解答写入答题纸的对应栏内。【说明】下面的程序的功能是利用实现Runnable接口的方法来创建线程,并利用它来执行响应的一些操作。最后使得m的执行结果:100,如图3。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。class ClassName (1) Runnable{int n;(2) {try{ThreaD.sleep(2000);n=100;}catch( (3) e){}}public static void main(String[]args){try{ClassName a=new ClassName();(4)thread1. (5) ();thread1.join();int m=A.n;System.out.println("m="+m);}catch( (3) e){}}}

阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。【Java代码】interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}

Java程序中,main方法的格式正确的是()A.public static void main(String[] args)B.public static main(String[] args)C.public void main(String[] args)D.static void main(String[] args)

Java程序中,main方法的格式正确的是()。A.static void main (string[] args)B.public void main (string[] s)C.public static main (string[] args)D.public static void main (string[] args)

main方法是Java应用程序执行的入口点,下面main方法的方法头合法的是()A.public static void main()B.public static void main(String[] args)C.public static void Main(String[] args)D.public static int main(String[] args)