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

问题:[选择题]

[单项选择题] 下面程序段的输出结果为 public class Test {public static void main(String args[]){ boolean a,b,c; a=(3<5); b=(a==true); System.out.printin( "a="+a+"b="+b) ; c-(b==false); System.out.println(b="+b+"e="+c) ;} }


A.a=trueb=falseb=truec=false
B.a=trueb=falseb=truec=true
C.a=trueb=trueb=truec=false
D.a=falseb=falseb=truec=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正确。

微信端