下面程序段的输出结果为( )。 public class Test { public static void mai n(Stri ng args[]) { booleana,b ,c ; a=(3<5); b =(a==true); Syste m.o

admin2012-12-02  60

问题 下面程序段的输出结果为(  )。
public class Test

public static void mai n(Stri ng args[])

booleana,b ,c ;
a=(3<5);
b =(a==true);
Syste m.out .pri ntln("a="+a+"b ="+b);
c =(b ==false);
Syste m.out .pri ntln("b ="+b +"c ="+c);


选项 A、a=true b =falseb =true c =true
B、a=true b =falseb =true c =false
C、a=true b =trueb =true c =false
D、a=false b =falseb =true c =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正确。
转载请注明原文地址:https://kaotiyun.com/show/QBID777K
0

相关试题推荐
最新回复(0)