当前位置:IT认证>软件水平

问题:[选择题]

[单项选择题] 下面程序段的输出结果为( )。 pubUCClassTeS { public static voidmain(StringargS[]) { booleaha,b,c; a=(3<5); b=(a==tme); System.Out.phntln("a="+a+"b="+b); c=(b==false); SyStem.out.println("b="+b+"C="+c); } }


A.a=tmeb=falSe
B.a=trueb=falseb=truec=falseb=trueC=tme
C.a=trueb=true
D.a=falSeb=falseb=truec=falSeb=tmec=falSe

参考答案: C

  参考解析

本题考查关系运算符<和==。题目中a=(3<5);比较3和5的大小,因为3<5,返回true给a;b=(a==true);判断a是否为真,因为a确实为真,返回true给b;c=(b=false);判断b是否为假,因为b不为假,返回false给c。最后结果a=true,b=true,b=true,c=false,选项C正确。

微信端