对于以下代码: 1. int i=6; 2. if (i<= 6 ) 3. System.out.println("hello"); 4. else 5. System.out.println("bye-bye");A.打印出“hello”B.打印出“bye-bye"C.不能编译D.打印出”hello bye-bye“

对于以下代码: 1. int i=6; 2. if (i<= 6 ) 3. System.out.println("hello"); 4. else 5. System.out.println("bye-bye");

A.打印出“hello”

B.打印出“bye-bye"

C.不能编译

D.打印出”hello bye-bye“


参考答案和解析
ABD

相关考题:

以下代码的运行结果是______。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);}}

( 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 ()

请阅读下面程序 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.以上都不对

下列选项中,不能输出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,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.以上都不对

下列代码的执行结果是( )。 int length=”Hello”.length( ); System.OUt.println(length);A.5B.2C.10D.6

以下选项中循环结构合法的是( )。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);

以下代码段的输出结果为1. int x = 0, y = 4, z = 5;2. if (x >2、{3. if (y 以下代码段的输出结果为1. int x = 0, y = 4, z = 5;2. if (x >2、{3. if (y4. System. out .println ( "message one" );5. }6. else {7. System.out.println( "message two");8. }9. }10. else if (z >5、{11. System.out.println("message three");12. }13. else {14. System.out.println( "message four");15. }A. message oneB. message twoC. message threeD. message four

以下程序的运行结果为:1. public class Conditional {2. public static void main(String args [] ) {3. int x = 4;4. System.out.println( "value is " +((x >4、? 99.99 : 9));5. }6. } A. 输出:value is 99.99B. 输出: value is 9C. 输出: value is 9.0D. 在第4行出现编译错误

以下程序的编译和运行结果为?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 EqualsTest{2. public static void main(String args[]){3. byte A=(byte)4096;4. if(A== 4096、System.out.println("Equal");5. else System.out.println("Not Equal");6. }7. }A.在第3行出现转换丢失精度的编译错误.B.输出 "Not Equal".C.输出 "Equal".

关于以下程序段,正确的说法是1. String s1="Hello";2. String s2="Hello";3. if(s1= =s2、4. System.out.println("s1= =s2");5. if (s1.equals(s2、)6. System.out.println("s1.equals(s2、");A. 行4与行6都将执行B. 行4执行,行6不执行C. 行6执行,行4不执行D. 行4、行6都不执行

考虑如下类:1. class Test(int i) {2. void test(int i) {3. System.out.println("I am an int.");4. }5. void test(String s) {6. System.out.println("I am a string.");7. }8.9. public static void main(String args[]) {10. Test t=new Test();11. char ch="y";12. t.test(ch);13. }14. }以下哪条为真?A.行 5 不能通过编译,方法不能被覆盖.B.行 12 不能通过编译, 因为没有一个test()方法含字符参数.C.代码可以编译但在12行将出现异常.D.代码可以编译且产生如下输出: I am an int.E.代码可以编译且产生如下输出: I am a String.

研究下面的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));

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

1. public class Test {  2. int x= 12;  3. public void method(int x) {  4. x+=x;  5. System.out.println(x);  6. }  7. }  Given:  34. Test t = new Test();  35. t.method(5);  What is the output from line 5 of the Test class?() A、 5B、 10C、 12D、 17E、 24

1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A、 0B、 3C、 4D、 5E、 The code will not compile.

单选题1. public class Test {  2. int x= 12;  3. public void method(int x) {  4. x+=x;  5. System.out.println(x);  6. }  7. }  Given:  34. Test t = new Test();  35. t.method(5);  What is the output from line 5 of the Test class?()A 5B 10C 12D 17E 24

单选题1. public class Boxer1 {  2. Integer i;  3. int x;  4. public Boxer1(int y) {  5. x=i+y;  6. System.out.println(x);  7. }  8. public static void main(String[] args) {  9. new Boxer1(new Integer(4));  10. }  11. }  What is the result?()A The value “4” is printed at the command line.B Compilation fails because of an error in line 5.C Compilation fails because of an error in line 9.D A NullPointerException occurs at runtime.E A NumberFormatException occurs at runtime.F An IllegalStateException occurs at runtime.

多选题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程序结束

单选题1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A 0B 3C 4D 5E The code will not compile.