29、对于以下代码: int i=6; if (i<= 6 ) System.out.println("hello"); else System.out.println("bye-bye"); 哪句话是对的?A.打印出“hello”B.打印出“bye-bye"C.不能编译D.打印出”hello bye-bye“
29、对于以下代码: int i=6; if (i<= 6 ) System.out.println("hello"); else System.out.println("bye-bye"); 哪句话是对的?
A.打印出“hello”
B.打印出“bye-bye"
C.不能编译
D.打印出”hello bye-bye“
参考答案和解析
编译失败
相关考题:
以下代码的运行结果是______。public class exl5{public static void main(String args []){int i = 5;do{i--;if(i > 2)continue;}while(i < 0);System.out.println(i);}}
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内【说明】编写字符界面的Application程序,接收依次输入的10个整型数据,每个数据一行,将这些数据按升序排序后从系统的标准输出设备输出。【Java代码】import java.iO.*;import java.util.* ;public class compositor{public static void main ( String args[] ){final int NUMBER=10;Vector dataVector=new Vector ();try{BufferedReader br=new BufferedReader ((1) InputStreamReader ( System.in ));System.out.println ("请输入"+NUMBER+"个整数");for (int i=0; i<NUMBER; i++ ){int temp=Integer.parselnt ( br.(2));int low=0, high=i-1, mid=0;while ((3)){System.out.println ( low+","+mid+","+high );(4);if ((( Integer ) dataVectOr.get( mid )) .intValue () ==temp ){data Vector.insertElementAt ( new Integer ( temp ), mid );break;}else if ((( Integer ) dataVector.get ( mid )) .intValue ( ) >temp ){high=mid-1;}else{(5);}}if ( low>high ){dataVector, insertElementAt ( new Integer ( temp ), iow );}}//输出System.out.println ( "\n升序的排序结果为; ");for (int i=0; i<NUMBER; i++ ){System.out.print ( dataVector.get( i ) .toString () +"\t" );}}catch ( NumberFormatException nfe){System.out.println ( nfe.toString ());System.out.println ( "整数格式输入错误。");}catch ( IOException ioe ){System.out.println ( ioe.toString ());}}}
( 28 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]) throws Exception {int i=0;Hello t = new Hello ();___________;whlle ( true ){System.out.println ( "Good Morning"+i++ ) ;if ( i=2 && t.isAlive ()){System.out.println ( "Main waiting for Hello ! ” );tjoin () ; // 等待 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.yieldn ()C ) t.interrupt ()D ) t.start ()
下列代码的执行结果是______。Int length="Hello", length();System.out.println(lenght);A) 5B) 2C) 10D) 6A.B.C.D.
请阅读下面程序 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
下列选项中哪一个编译不出现错误 ( )A.int i=0; if(i){ System.out.println("Hi"); }B.int il=5; int i2=5; if(i1=i2){ System.out.println("So true"); }C.int i=1; int j=2; if(i==1||j==2) System.out.println("OK");D.int i=1; int j=2; if (i==1 |j==2) System.out.println("OK");
设有数组定义: int a[] = {11, 22, 33, 44, 55, 6, 77, 88, 99};, 则执行下列几个语句后的输出结果是______、______和______。for(int i = O; i < a.tength; i++)if(a[i]%3.== 0) System.out.println(a[i]);
阅读下面代码 public class Arrays { public static void main(String[] args) { int[] a=new int[5]; for(int i=0;i<a.length;i=i+1)a[i]=10+i; for(int i=0;i<a.length;i=i+1)System.out.println(a[i]); String[] s={"Frank","Bob","Jim"}; for(int i=0;i<s.length;i=i+1)System.out.println(s[i]); s[2]="Mike"; System.out.println(s[2]); } } 代码运行正确的结果是A.10 11 12 13 14 Mike Bob Frank JimB.11 12 13 14 15 Frank Bob Mike JimC.10 11 12 13 14 Frank Bob Jim MikeD.11 12 13 14 15 Mike Jim Bob Frank
下面程序的输出结果是 public class Test{ public static void main(String[] args){ int[]array={2,4,6,8,10}; int size=6; int result=-1: try{ for(int i=0;i<sizeresult==-1;i++) if(array[i]==20)result=i; }catch(ArithmeticException e){ System.out.println("Catch---1"); }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Catch---2"); }catch(Exception e){ System.out.println("Catch---3"); } } }A.Catch---1B.Catch一--2C.Catch---3D.以下都不对
有下面程序段: Public class ArrayTest { Public static void main(String args[]) { int[] intArray=new int[3]; for(int I=0;I<3;I++) { intArray[I]=I+2; System.out.println("IntArray["+I+"]"="+intArray[I]); } System.out.println("--------------"); Int arrLen=4; IntArray=new int[arrLen]; For(int j=intArray.length;j>=0;j--) { intArray[j]=j*3; System.out.println("hello"+intArray[j]); } } } 则运行的结果是( )。A.编译出错B.编译通过,但运行出错C.可以运行,但有错误D.以上都不对
下列程序执行后,k的值是 ( ) public class Testhhh { publicstaticvoidmain(Stnngargs[]) { int i=6,j=8,k=10,m=7; if(i>j||m<k- -) k+ +; else k--; System.out.println(k);A.12B.11C.10D.9
下列选项中,不能输出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 Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;isizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对
下列程序的输出结果是( )。 public class Test{ public static void main(String[]args){ int[]array=(2,4,6,8,lO); int size=6; int result =-1: try{ for(int i=0;i(size 8Lresult= = -1;) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch- - -l"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch- - -2"); } catch(Exception e){ System.out.println("Catch- - -3");) } }A.Catch- - -1B.Catch- - -2C.Catch- - -3D.以上都不对
以下选项中循环结构合法的是( )。A.while (int i<7) { i+ + System.out.println("i is" + i): }B.int j:3; while (j) { System.out.println("j is"+j); }C.int j=O; for (int k=0; j + k!=10; j + +, k+ +) { System.out.println("j is"+j +,"k is"+ k): }D.int i=0: do{ {System.out.println("j is"+ j+ +); if (j==3){continue loop;} }while(j<10);
以下程序的编译和运行结果为?class test {static boolean check;public static void main(String args[]) {int i;if(check == true)i=1;elsei=2;if(i= 2、i=i+2;else i = i + 4;System.out.println(i);}} A. 3B. 4C. 5D. 6E. 语句if(i= 2、编译出错
以下程序的编译运行结果为:1: public class Q102: {3: public static void main(String[] args)4: {5: int i = 10;6: int j = 10;7: boolean b = false;8:9: if( b = i == j)10: System.out.println("True");11: else12: System.out.println("False");13: }14: }A. 第9行出现编译错误;B. 第9行出现运行错误;C. 输出 TrueD. 输出 False
在注释//Start For loop 处要插入哪段代码可实现根据变量i的值定位数组ia[]的元素?public class Lin{public void amethod(){int ia[] = new int[4];//Start For loop{ia[i]=i;System.out.println(ia[i]);}}} A. for (int i=0; iB. for (int i=0; iC. for (int i=1; iD. for (int i=0; i
若用白盒测试方法测试以下代码,并满足条件覆盖,则至少需要( )个测试用例Int find _max(int i,int j,int k){ int max;if(i>j)then if(i>k)then max =i; else max=k; else if(j>k)then max =j; else max=k; } A.3 B.4 C.5 D.6
int i = 1,j = 10; do{ if (ij) { continue; } j--; } while (++i 6); System.out.println(“i = “ +i+” and j = “+j); What is the result?() A、 i = 6 and j = 5B、 i = 5 and j = 5C、 i = 6 and j = 4D、 i = 5 and j = 6E、 i = 6 and j = 6
研究下面的Java代码: public class testException{ public static void main(String args[]){ int a[]={0,1,2,3,4}; int sum=0; try{ for(int i=1;i6;i++) sum=sum+a[i]; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsException ){ System.out.println("数组越界"); } finally{ System.out.println("程序结束");} } } 输出结果将是()。 A、10 数组越界 程序结束B、10 程序结束C、数组越界 程序结束D、程序结束
ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()A、 for (int i=0; i a.size(); i++) System.out.println(a.get(i)));B、 for (int i=0; i a.size(); i++) System.out.println(a[i]);C、 while( iter.hasNext() ) System.out.println(iter.next()) ;D、 for (int i=0, i a.size(); i++) System.out.println(iter[i]);E、 for (int i=0; i a.size(); i++) System.out.println(iter.get(i));
int i = 1,j = 10; do { if(ij) { break; } j--; } while (++i 5); System.out.println(“i =” +i+” and j = “+j); What is the result?()A、 i = 6 and j = 5B、 i = 5 and j = 5C、 i = 6 and j = 4D、 i = 5 and j = 6E、 i = 6 and j = 6
多选题ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()Afor (int i=0; i a.size(); i++) System.out.println(a.get(i)));Bfor (int i=0; i a.size(); i++) System.out.println(a[i]);Cwhile( iter.hasNext() ) System.out.println(iter.next()) ;Dfor (int i=0, i a.size(); i++) System.out.println(iter[i]);Efor (int i=0; i a.size(); i++) System.out.println(iter.get(i));
单选题研究下面的Java代码: public class testException{ public static void main(String args[]){ int a[]={0,1,2,3,4}; int sum=0; try{ for(int i=1;i6;i++) sum=sum+a[i]; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsException ){ System.out.println("数组越界"); } finally{ System.out.println("程序结束");} } } 输出结果将是()。A10 数组越界 程序结束B10 程序结束C数组越界 程序结束D程序结束