inti=0;while(true){if(i==4){break;}++i;}System.out.println(i=”+i);Whatistheresult?() A.i=0B.i=3C.i=4D.i=5E.Compilationfails.
inti=0;while(true){if(i==4){break;}++i;}System.out.println(i=”+i);Whatistheresult?()
A.i=0
B.i=3
C.i=4
D.i=5
E.Compilationfails.
相关考题:
请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 t.isAlive()) { System. out.println("Main waiting for Hello!"); t.join(); //等待t运行结束 } if(i==5) break;} } } class Hello extends Thread { int i; public void run() { while(true){ System.out.println("Hello"+i++); if (i==5) break;}}} 为使该程序正确执行,下划线处的语句应是A.t.sleep()B.t.yield()C.t.interrupt()D.t.start()
请阅读下面程序 public class ThreadTest{ public static void main(String args[])throws Ex- ception{ int i=0; Hello t=new Hello; ; while(true){ System.Out.println("Good Morning"+i++): if(i= =2t.isAlive){ System.out.println("Main waiting for Hel- lo!"); join;//等待t运行结束 } if(i= =5)break;} } } class Hello extends Thread{ int l; public void run{ while(true)( System.Out.println("Hell0"+i++); if(i= =5)break;)))A.t.sleepB.t.yieldC.t.interruptD.t.start
public static void main(String[]args){for(inti=0;i=10;i++){if(i6)break;}System.out.println(i);}What is the result?() A.6B.7C.10D.11E.Compilation fails.F.Anexception is thrown at runtime.
inti=1,j=10;do{if(ij){break;}j--;}while(++i5);System.out.println(i=”+i+”andj=+j);Whatistheresult?() A.i=6andj=5B.i=5andj=5C.i=6andj=4D.i=5andj=6E.i=6andj=6
请阅读下面程序 publicclassThreadTest{ publicstaticvoidmain(Stringargs[])throwsException{ inti=0; Hellot=newHello(); ______, while(true){ System.out.println("GoodMoming"+i++); if(i==2t.isAlive()){ System.out.println("MainwaitingforHello!"); t.join();//等待t运行结束 } if(i==5)break;} } } classHelloextendsThread{ inti; publicvoidrun(){ while(true){ System.out.println("Hello"+i++); if(i==5)break;}}} 为使该程序正确执行, 下划线处的语句应是( )。A.t.sleep()B.t.yield()C.t.interrupt()D.t.start()
下列选项中,不能输出100个整数的是( )。A.for(int i=0;i100;i++) System.out.println(i);B.int i=0; do{ System.out.println(i); i++; }while(i100);C.int i=0; while(i100){ System.out.println(i); i++; }D.int i=0; while(i100){ i++; if(i100)continue; System.OUt.println(i); }
下列选项中,不能输出100个整数的是( )。A.for(int i=0;i100;i++) System.out.println(i);B.int i=0; do{ System.out.println(i); i++: }while(i100);C.int i=0: while(i100){System.out.println(i); i++: }D.int i=0: while(i100){ i++: if(i100)continue: System.out.println(i); }
【分录题】写出以下程序运行结果。 public class Demo8 { public static void main(String[] args) { int sum=0; while(true) { for(int i=1,j=2;i<10;i++) { if(i*j%3==0) continue; sum=sum+i; } if(sum>20) break; } System.out.println(sum); } }
3、下列循环语句合法的是()A.while(int i<7){ System.out.println(“i is ”+i); i++; }B.int i=1; while(i){ System.out.println(“i is ”+i); }C.int i=0; for(int i=0;i<7;i++){ System.out.println(“i is ”+i); }D.int i=0; do{ System.out.println(“i is ”+i++); if(i==3) continue; }while(i<7);