7、以下代码片段编译运行的结果是:int Output=10; boolean b1 = false; if((b1==true) ((Output+=10)==20)){ System.out.println("We are equal "+Output); } else { System.out.println("Not equal! "+Output); }A.输出"Not equal! 10"B.编译错误C.输出"We are equal 10"

7、以下代码片段编译运行的结果是:int Output=10; boolean b1 = false; if((b1==true) && ((Output+=10)==20)){ System.out.println("We are equal "+Output); } else { System.out.println("Not equal! "+Output); }

A.输出"Not equal! 10"

B.编译错误

C.输出"We are equal 10"


参考答案和解析
D

相关考题:

已知如下代码: boolean m=true; if(m==false) System.out.prinfln("False"); else System.out.println("True");A.假B.真C.NoneD.An error will occur when running

下面程序的输出为( )。 public class Test { public static void main (String args[]) { int x,y; x=1; y=2; System.out.println("The output is"+x+y); } }A.The output is xyB.The output is 3C.The output is 12D.The output is x=1 y=2

下面程序执行后,输出的结果是( )。 public class Test { public static void main (String[] )args) { boolean m=true; if(m==false) System.out.println("假"); else if(m====true) System.out.println("真"); else System.out.println ("错误"); } }A.真B.假C.错误D.编译出错

已知如下代码: boolean m = true; if ( m = false ) System.out.println("False"); else System.out.println("True"); 执行结果是什么?() A.FalseB.TrueC.编译时出错D.运行时出错

已知如下代码: boolean m=true; if (m==false) System.out.println("False"); else System.out.println("True"); 执行结果是( )。A.假B.TreeC.NoneD.An error will occur when running

阅读下面程序import javax.swing.JOptionPane;public class BreakLabelTest{public static void main (String args[]){String utput=" ";stop:{for(int row=1;row<10;row++){for(int column=1;column<=5;column++){if(row=5)break stop;output+=" * ";}output+=" \n ";}output+="\nLoops terminated normally";}JOptionPane.showMessageDialog(null,output,"用一个标志测试break语句”,JOptionPane.INFORMATION_MESSAGE);System.exit(0);}}程序运行结果是A.窗口中有5行* * * * *B.窗口中有5行* * * *C.窗口中有4行* * * * *D.窗口中有6行* * * * *

阅读下面程序import javax.swing.JOptionPane;public class BreakLabelTest {public static void main(String args[]) {String utput=" ":stop:{for(int row=1;row<=10;row++) {for(int column=1;column<=5;colunm++) {if(row==5)break stop;output+="*":}output+="\n";}output+="\nLoops terminated normally":}JOptionPane.showMessageDialog(null,output,"用一个标志测试break语句",JOptionPane.INFORMATION_MESSAGE);System.exit(0);}}程序运行的结果是A.窗口中有5行*****B.窗口中有5行****C.窗口中有4行*****D.窗口中有6行*****

已知如下代码: public class Test long a[]=new long[10] public static void main (String args[]{ System.out.println(a[6];} 以下( )语句是正确的。A.Output is null.B.When running,some error will occur.C.When compile,some error will occur.D.Output is 0.

阅读下面程序importjavax.swing.JOptionPane;publicclassBreakLabelTest{publicstaticvoidmain(Stringargs[]){Stringoutput="";stop:{for(introw=1;row<=10;row++){for(intcolumn=1;column<=5;column++){if(row=5)breakstop;output+="*";}output+="\n";}output+="\nLoopsterminatednormally";}JOptionPane.showMessageDiaiog(null,output,"用一个标志测试break语句",JOptionPane.INFORMATION_MESSAGE);System.exit(0);}}程序运行结果是()。A.窗口中有5行*****B.窗口中有5行****C.窗口中有4行*****D.窗口中有6行*****

已知如下代码: boolean m=tree; if(m==false) System.out.println("False"); else System.out.pfintln("True"); 执行结果是( )。A.FalseB.TrueC.无结果D.运行时出错

下列代码段的执行结果是( )。 public class Test { public static void main(String args[ ]) { String s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }A.true falseB.true trueC.false trueD.false false

编译和运行以下代码结果为: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: 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

以下程序的运行结果为class Prob10 {static boolean b1;public static void main(String [] args) {int i1 = 11;double f1=1.3;do {b1 = (f1 >4、} while (!b 1、;System.out.println(b1 + "," + i1 + "," + f 1、;}}A. false,9,4.3B. true,11,1.3C. false,8,1.3D. true,8,7.3

public void foo( boolean a, boolean b ){  if( a ) {  System.out.println( “A” );  } else if ( a  b ) {  System.out.println( “AB” );  } else { 17. if ( !b ) {  System.out.println( “notB” );  } else {  System.out.println( “ELSE” );  }  } }  What is correct?()  A、 If a is true and b is true then the output is “AB”.B、 If a is true and b is false then the output is “notB”.C、 If a is false and b is true then the output is “ELSE”.D、 If a is false and b is false then the output is “ELSE”.

public void test(int x) {  int odd = x%2;  if (odd) {   System.out.println(“odd);  } else {  System.out.println(“even”);  }  }  Which statement is true?() A、Compilation fails.B、 “odd” will always be output.C、 “even” will always be output.D、 “odd” will be output for odd values of x, and “even” for even values.E、 “even” will be output for add values of x, and “odd” for even values.

boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()  A、 aB、 bC、 cD、 dE、 Compilation fails.

public class Alpha1 {  public static void main( String[] args ) {  boolean flag; int i=0;  do {  flag = false;  System.out.println( i++ );  flag = i  10;  continue;  } while ( (flag)? true:false );  }  }  What is the result?()  A、 000000000B、 0123456789C、 Compilation fails.D、 The code runs with no output.E、 The code enters an infinite loop.F、 An exception is thrown at runtime.

Given the following code:     public class Person{     int arr[] = new int[10];  public static void main(String a[]) {     System.out.println(arr[1]);     }     }  Which statement is correct?() A、 When compilation some error will occur.B、 It is correct when compilation but will cause error when running.C、 The output is zero.D、 The output is null.

public class IfTest (  public static void main(string[]args) {  int x = 3;  int y = 1;  if (x = y)  system.out.printIn(“Not equal”);  else  system.out.printIn(“Equal”);  }  )   What is the result?()      A、 The output is “Equal”B、 The output in “Not Equal”C、 An error at line 5 causes compilation to fall.D、 The program executes but does not print a message.

class Ifs{   public static void main(String[] args){   boolean state=false;   int i=1;   if((++i1)(state=true))   i++;   System.out.println(i);  }  } 结果是()  A、5B、编译失败C、运行时异常被抛出D、3E、4

try {  if ((new Object))(.equals((new Object()))) {  System.out.println(“equal”);  }else{  System.out.println(“not equal”);  }  }catch (Exception e) {  System.out.println(“exception”);  }   What is the result? () A、 equalB、 not equalC、 exceptionD、 Compilation fails.

public class IfTest (   public static void main(stringargs) {   int x = 3;  int y = 1;   if (x = y)   system.out.printIn(“Not equal”);   else   system.out.printIn(“Equal”);   }   )   What is the result?()A、 The output is “Equal”B、 The output in “Not Equal”C、 An error at line 5 causes compilation to fall.D、 The program executes but does not print a message.

单选题public void foo( boolean a, boolean b ){  if( a ) {  System.out.println( “A” );  } else if ( a  b ) {  System.out.println( “AB” );  } else { 17. if ( !b ) {  System.out.println( “notB” );  } else {  System.out.println( “ELSE” );  }  } }  What is correct?()A If a is true and b is true then the output is “AB”.B If a is true and b is false then the output is “notB”.C If a is false and b is true then the output is “ELSE”.D If a is false and b is false then the output is “ELSE”.

单选题boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()A aB bC cD dE Compilation fails.

单选题public void test(int x) {  int odd = x%2;  if (odd) {   System.out.println(“odd);  } else {  System.out.println(“even”);  }  }  Which statement is true?()ACompilation fails.B “odd” will always be output.C “even” will always be output.D “odd” will be output for odd values of x, and “even” for even values.E “even” will be output for add values of x, and “odd” for even values.

单选题public class IfTest (  public static void main(string[]args) {  int x = 3;  int y = 1;  if (x = y)  system.out.printIn(“Not equal”);  else  system.out.printIn(“Equal”);  }  )   What is the result?()A The output is “Equal”B The output in “Not Equal”C An error at line 5 causes compilation to fall.D The program executes but does not print a message.

单选题class Ifs{   public static void main(String[] args){   boolean state=false;   int i=1;   if((++i1)(state=true))   i++;   System.out.println(i);  }  } 结果是()A5B编译失败C运行时异常被抛出D3E4