3.14.
Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and "Can get a driver's license" if age is greater than or equal to 16. Which of the following code is correct?
I:
if (age < 16)
System.out.println("Cannot get a driver's license");
if (age >= 16)
System.out.println("Can get a driver's license");
II:
if (age < 16)
System.out.println("Cannot get a driver's license");
else
System.out.println("Can get a driver's license");
III:
if (age < 16)
System.out.println("Cannot get a driver's license");
else if (age >= 16)
System.out.println("Can get a driver's license");
IV:
if (age < 16)
System.out.println("Cannot get a driver's license");
else if (age > 16)
System.out.println("Can get a driver's license");
else if (age == 16)
System.out.println("Can get a driver's license");
回答错误
多选题 (2 分) 0 分
- A.
IV
- B.
I
- C.
II
- D.
III
16.
The conditional operator ? : is a ______
回答错误
单选题 (1 分) 0 分
- A.
ternary operator(三元运算符)
- B.
unary operator
- C.
binary operator
18.
Which of the Boolean expressions below is incorrect?
回答错误
多选题 (2 分) 0 分
- A.
(true) && (3 => 4)
- B.
(x != 0) || (x = 0)
- C.
(x > 0) || (x < 0)
- D.
(-10 < x < 0)
- E.
!(x > 0) && (x > 0)
23.
You can cast a Boolean value to an int, or an int to Boolean.
判断题 (2 分) 2 分
- A.
true
- B.
false
两者在Java中不可以相互转换
27.
The order of the precedence (from high to low) of the operators binary +, *, &&, ||, ^ is:
单选题 (1 分) 1 分
- A.
&&, ||, ^, *, +
- B.
^, ||, &&, *, +
- C.
*, +, ^, &&, ||
- D.
*, +, ^, ||, &&
- E.
*, +, &&, ||, ^
29.
System.exit(0) can be used to terminate the program.
判断题 (2 分) 2 分
- A.
true
- B.
false
40.
What is 1 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5?
单选题 (1 分) 1 分
- A.
false
- B.
true
- C.
There is no guarantee that 1 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5 is true.
emmm,我运行的结果是false。。不晓得c选项啥意思。。。
44.
The binary operator + is left-associative.
判断题 (2 分) 2 分
- A.
true
- B.
false
45.
Analyze the following code fragments that assign a boolean value to the variable even.
Code 1:
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
even = (number % 2 == 0) ? true: false;
Code 3:
even = number % 2 == 0;
回答错误
单选题 (1 分) 0 分
- A.
Code 3 has a compile error, because you attempt to assign number to even.
- B.
All three are correct, but Code 1 is preferred.
- C.
Code 2 has a compile error, because you cannot have true and false literals in the conditional expression.
- D.
All three are correct, but Code 3 is preferred.
- E.
All three are correct, but Code 2 is preferred.
53.
Which of the following operators are right-associative.
单选题 (1 分) 1 分
- A.
%
- B.
=
- C.
+ (binary +)
- D.
&&
- E.
*
57.
Which of the following are so called short-circuit operators?
多选题 (2 分) 2 分
- A.
||
- B.
&&
- C.
&
- D.
|