网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicvoidtest(intx){intodd=x%2;if(odd){System.out.println(odd);}else{System.out.println(even”);}}Whichstatementistrue?()
A.Compilationfails.
B.“odd”willalwaysbeoutput.
C.“even”willalwaysbeoutput.
D.“odd”willbeoutputforoddvaluesofx,and“even”forevenvalues.
E.“even”willbeoutputforaddvaluesofx,and“odd”forevenvalues.
参考答案
更多 “ publicvoidtest(intx){intodd=x%2;if(odd){System.out.println(odd);}else{System.out.println(even”);}}Whichstatementistrue?() A.Compilationfails.B.“odd”willalwaysbeoutput.C.“even”willalwaysbeoutput.D.“odd”willbeoutputforoddvaluesofx,and“even”forevenvalues.E.“even”willbeoutputforaddvaluesofx,and“odd”forevenvalues. ” 相关考题
考题
如下代码:publicvoidTest(){try{oneMethod();System.out.println(condition1);}catch(ArrayIndexOutOfBoundsExceptione){System.out.println(condition2);}catch(Exceptione){System.out.println(condition3);}finally{System.out.println(finally);}}如果oneMethod正常运行,则输出结果中是?()A.condition1finallyB.condition2finallyC.condition3finallyD.finally
考题
对输入一个整数进行判断,若是偶数,输出even,否则输出odd,在子函数fun2功能是判定整数是否为偶数,若是偶数,返回1,否则返回0int fun2(int x){if(x%2==0);return 0;}main(){int n;scanf("%d",n);ifprintf("even\n");else printf(odd\n");}
考题
下列代码中if(xO){System.out.println(first);}elseif(x-3){System.out.println(second);)else{System.out.println(third);)要求打印字符串为“second”时,X的取值范围是( )。A.x-3B.x>0C.x>-3D.x
考题
Giventhefollowingcode:if(x0){System.out.println(first);}elseif(x-3){System.out.println(second);}else{System.out.println(third);}Whichrangeofxvaluewouldprintthestringsecond?()A.x0B.x-3C.x=-3D.x=0x-3
考题
publicvoidfoo(booleana,booleanb){if(a){System.out.println(A”);}elseif(ab){System.out.println(AB”);}else{17.if(!b){System.out.println(notB”);}else{System.out.println(ELSE”);}}}Whatiscorrect?()A.Ifaistrueandbistruethentheoutputis“AB”.B.Ifaistrueandbisfalsethentheoutputis“notB”.C.Ifaisfalseandbistruethentheoutputis“ELSE”.D.Ifaisfalseandbisfalsethentheoutputis“ELSE”.
考题
2给出下面代码段,x处于( )范围时打印字符串“second”。 pubhc class forLoopStatement{ public static voidmain(String[]args){ int x=______;//给x赋值 if(x>0) {System.out.println("second"); } else if(x>-3) {System.out.println("second"); } else { System.out.printlnCthird"); } } }A.x>0B.x>-3C.x<=-3D.x<=0 x>-3
考题
给出下面代码段:x处于什么范围时打印字符串“second”。 ( ) public class forLoopStatement { public static void main(String[]args) { int x=______;//给x赋值 if(x>0){System.out.println("first");} else if(x>-3){System.out.println("second");} else{System.out.println("third");} } }A.x>0B.x>-3C.x<=-3D.x<=0x>-3
考题
【分录题】写出以下程序运行结果。 public class Demo7 { public static void main(String[] args) { int i=1,j=0; int x=2; while(x<13) { for(;;) { if(i*j>10) break; i++; j++; } x=x+2; } System.out.println(x); System.out.println(i); System.out.println(j); } }
考题
【填空题】请先阅读下面的代码。 int x = 1; int y = 2; if (x % 2 == 0) { y++; } else { y--; } System.out.println("y=" + y); 上面一段程序运行结束时,变量y的值为_____________。
热门标签
最新试卷