网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

publicclassXimplementsRunnable(privateintx;privateinty;publicstaticvoidmain(Stringargs)(Xthat=newX();(newThread(that)).start();(newThread(that)).start();)publicsynchronizedvoidrun()(for(;;)(x++;y++;System.out.printIn(x=+x+,y=+y);)))Whatistheresult?()

A.Anerroratline11causescompilationtofail.

B.Errorsatlines7and8causecompilationtofail.

C.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”)

D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=1,y=1”)

E.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=2s,y=2”)


参考答案

更多 “ publicclassXimplementsRunnable(privateintx;privateinty;publicstaticvoidmain(Stringargs)(Xthat=newX();(newThread(that)).start();(newThread(that)).start();)publicsynchronizedvoidrun()(for(;;)(x++;y++;System.out.printIn(x=+x+,y=+y);)))Whatistheresult?()A.Anerroratline11causescompilationtofail.B.Errorsatlines7and8causecompilationtofail.C.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”)D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=1,y=1”)E.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=2s,y=2”) ” 相关考题
考题 1.publicclassXimplementsRunnable(2.privateintx;3.privateinty;4.5.publicstaticvoidmain(String[]args)6.Xthat=newX();7.(newThread(that)).start();8.(newThread(that)).start();9.)10.11.publicvoidrun()(12.for(;;)(13.x++;14.y++;15.System.out.printIn(x=”+x+,y=”+y);16.)17.)Whatistheresult?()A.Errorsatlines7and8causecompilationtofail.B.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”).C.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=1,y=1”).D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearsonlyforonce(forexample,“x=1,y=1”followedby“x=2,y=2”).

考题 publicclassXimplementsRunnable(privateintx;privateinty;publicstaticvoidmain(String[]args)(Xthat=newX();(newThread(that)).start();(newThread(that)).start();)publicsynchronizedvoidrun()(for(;;)(x++;y++;System.out.printIn(x=+x+,y=+y);)))Whatistheresult?()A.Anerroratline11causescompilationtofail.B.Errorsatlines7and8causecompilationtofail.C.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”)D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=1,y=1”)E.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=2s,y=2”)

考题 publicclassXimplementsRunnable{privateintx;privateinty;publicstaticvoidmain(String[]args){Xthat=newX();(newThread(that)).start();(newThread(that)).start();}publicvoidrun(){for(;;){synchronized(this){x++;y++;}System.out.println(Thread.currentThread().getName()+x=+x+,y=+y);}}}Whatistheresult?()A.Compilationfails.B.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”).C.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”). Inaddition,eachvalueappearsonlyonce(forexample,“x=1,y=1”followedby“x=2,y=2”). Thethreadnameatthestartofthelineshowsthatboththreadsareexecutingconcurrently.D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”). Inaddition,eachvalueappearsonlyonce(forexample,“x=1,y=1”followedby“x=2,y=2”). Thethreadnameatthestartofthelineshowsthatonlyasinglethreadisactuallyexecuting.

考题 publicclassSyncTest{privateintx;privateinty;privatesynchronizedvoidsetX(inti){x=i;}privatesynchronizedvoidsetY(inti){y=i;}publicvoidsetXY(inti){setX(i);setY(i);}publicsynchronizedbooleancheck(){returnx!=y;}}Underwhichconditionwillcheckreturntruewhencalledfromadifferentclass?()A.checkcanneverreturntrue.B.checkcanreturntruewhensetXYiscalledbymultiplethreads.C.checkcanreturntruewhenmultiplethreadscallsetXandsetYseparately.D.checkcanreturntrueonlyifSyncTestischangedtoallowxandytobesetseparately.

考题 以下哪个是Java应用程序main方法的有效定义? A. public static void main();B. public static void main( String args );C. public static void main( String args[] );D. public static void main( Graphics g );E. public static boolean main( String a[] );

考题 下面哪个是Java应用程序主类中正确的main方法?A.public void main(String args[])B.static void main(String args[])C.public static void main(String args[])D.public static void Main(String args[])

考题 下面那个是java应用程序主类中正确的main方法?A.public void main(String args[])B.static void main(String args[])C.public static void Main(String args[])D.public static void main(String args[])

考题 下列哪个是Java应用程序主类中正确的main方法?A.public void main (String args[ ])B.static void main (String args[ ])C.public static void Main (String args[])D.public static void main (String args[ ])

考题 Java应用程序的main方法头的格式是_______。A.public static int main(char args[ ])B.public static void main(String[] args)C.public static void MAIN(String args[ ])D.public static void main(String args)