[单项选择题] 以下程序段输出结果为( )。 class test_1 { public static void main(String args[]) { int x=0; boole

15 查阅

[单项选择题] 以下程序段输出结果为( )。 class test_1 { public static void main(String args[]) { int x=0; boolean b1,b2,b3,b4; b1=b2=b3=b4=true; x=(b1|b2&b3^b4)x++:--x; System.out.println(x); } }

A.1

B.0

C.2

D.3

参考答案:

B

在赋值语句x=(b1|b2&b3^b4)x+:—x中,存在3元运算符。b1|b2&b3^b4的运算结果为true,故应返回x++的结果,根据后缀运算符的特性,可知返回值为0。

计算机考试