我被问到
Given the definitions of a, b and c below, select the expressions that compile successfully and evaluate to true.
int a = 1; char b = 'a'; boolean c = false;
if (expression)
{System.out.println("True");}
else
{System.out.println("False");}
c==a //false
!c || a //false
b >= a //true
c = a //false
a - b - 96 //false
a + b > 0 //true
c = true //true
a < b //true
最佳答案
c==a
:不编译,不能将int
与boolean
进行比较。 !c || a
:不编译,不允许boolean || int
b >= a
:编译,评估为true
c = a
:无法编译,无法将int
值分配给boolean
a - b - 96
:编译,评估为-192 a + b > 0
:编译,评估为true
c = true
:编译,评估为true
(并将true
分配给c
)a < b
:编译,评估为true
https://stackoverflow.com/questions/7914673/
相关文章:
objective-c - UIAlertView dismissWithClickedButton
java - 编译时出现一个或多个错误的NetBeans项目
php - 使用PHP的exec()函数(或类似函数),如何显示终端错误输出?
compiler-construction - lex 使用来自 lex.yy.c 文件的 flex
compiler-errors - nant 构建文件使用 nant 0.86 而不是 0.91 a
c++ - 新手Chrome插件开发人员需要NPAPI入门方面的帮助
objective-c - 尽管导入了正确的 header ,但使用自定义类的编译器错误