publicvoidfoo(booleana,booleanb){if(a){System.out.println(A”);}elseif(a&&b){System.out.println(A&&B”);}else{17.if(!b){System.out.println(notB”);}else{System.out.println(ELSE”);}}}Whatiscorrect?()
A.Ifaistrueandbistruethentheoutputis“A&&B”.
B.Ifaistrueandbisfalsethentheoutputis“notB”.
C.Ifaisfalseandbistruethentheoutputis“ELSE”.
D.Ifaisfalseandbisfalsethentheoutputis“ELSE”.
第1题:
程序:classTestApp{publicstaticvoidmain(String[]args){intx=6;if(x>l)System.out.println("x>l");elseif(x>5)System.out.println("x>5");elseif(x<10)System.out.println("xSystem.out.println("x<29");elseSystem.out.println(以上都不是”);}}上述程序运行后的结果是哪项?()
A.x>5
B.x>l
C.x<10
D.x<29
第2题:
A.a
B.b
C.c
D.d
E.Compilationfails.
第3题:
执行下面的程序段后,B的值为多少? int x = 35; char z = 'A'; boolean B; B = ((x<15)&&(z<'z')); System.out.println(B);
第4题:
Giventhefollowingcode:if(x>0){System.out.println("first");}elseif(x>-3){System.out.println("second");}else{System.out.println("third");}Whichrangeofxvaluewouldprintthestring"second"?()
A.x>0
B.x>-3
C.x<=-3
D.x<=0&x>-3
x>0时打印"first",x>-3&&x<=0时打印"second",x<=-3时打印"third"。这个题目没有什么难的,只要理解if语句的语法就可以了。
第5题:
当执行下面代码时,会输出( )。 Boolean b1 = new Boolean(true); Boolean b2 = new Boolean(true); if (b1 == b2) if (bi.equals(b2)) System. out.printin ("a"); else System. out. println ("b"); else if (bi.equals(b2)) System. out.println ("c"); else System. out.printIn("d");
A.a
B.b
C.c
D.d