itgle.com

publicclassTest{publicstaticvoidmain(String[]args){intx=5;booleanb1=true;booleanb2=false;if((x==4)&&!b2)System.out.print(”l);System.out.print(”2);if((b2=true)&&b1)System.out.print(”3);}}Whatistheresult?()A.2B.3C.12D.23E.123F.Compilationfails.G.Auexception

题目

publicclassTest{publicstaticvoidmain(String[]args){intx=5;booleanb1=true;booleanb2=false;if((x==4)&&!b2)System.out.print(”l);System.out.print(”2);if((b2=true)&&b1)System.out.print(”3);}}Whatistheresult?()

A.2

B.3

C.12

D.23

E.123

F.Compilationfails.

G.Auexceptionalisthrownatruntime.


相似考题
更多“publicclassTest{publicstaticvoidmain(String[]args){intx=5;booleanb1=true;booleanb2=false;i ”相关问题
  • 第1题:

    publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?()

    A.finished

    B.Compilationfails.

    C.AnAssertionErroristhrown.

    D.AnAssertionErroristhrownandfinishedisoutput.


    参考答案:A

    Thisquestionisabittrickybecauseitlacksthefollowinginformation:Itshouldincludeastatementthatsayswhetherornotassertionsareenabled.Iftheyareindeedenabled,the
    correctionanswerisC.butiftheyarenot,thecorrectanswerisA.Assertionsarenotenabledbydefaultsoifthequestionisnotchanged,themostlogicalanswerisA.

  • 第2题:

    执行下列程序段之后,变量b的值为( )。 public class Test { public static void main (String[] args) { int i = 12; int j = 24; boolean b1 = true; booleanb=(j%i==0)&&(! b1) || (j/i! =2); System. out. println (B); } }

    A.true

    B.false

    C.0

    D.1


    正确答案:B
    解析:表达式执行次序为:首先做!b1得到false;然后做j%i==0得到true;再做j/i!=2得到false;然后做&&得到false;最后是||,得到false。

  • 第3题:

    执行下列程序段之后,变量b的值为______。 public class Test9 { public static void main(String[] args) { int i=12; int j=24; boolean b1=true; boolean b=(j%i== 0)&&(!b1) ||(j/i!=2); System.out.println(b); } }

    A.true

    B.假

    C.1

    D.0


    正确答案:B
    解析:表达式执行次序为:首先做!b1得到false:然后做j%i==0得到true;再做j/i!=2得到false:然后做&&得到false;最后是||得到false。

  • 第4题:

    publicclassAlpha1{publicstaticvoidmain(String[]args){booleanflag;inti=0;do{flag=false;System.out.println(i++);flag=i<10;continue;}while((flag)?true:false);}}Whatistheresult?()

    A.000000000

    B.0123456789

    C.Compilationfails.

    D.Thecoderunswithnooutput.

    E.Thecodeentersaninfiniteloop.

    F.Anexceptionisthrownatruntime.


    参考答案:B

  • 第5题:

    阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x <=3 ; x++){continue;System.out.print(x%2);}}}运行结果正确的是

    A.跳出循环,无输出

    B.0121

    C.01

    D.0123


    答案:A
    解析:continue语句的作用是终止本次循环,因此contine后的代码永远不会被执行,都是无效代码