6
Which of the Boolean expressions below has incorrect
syntax?
7
You can always convert an if statement to a switch
statement.
A. false
B. true
8
The default case must be specified in a switch statement.
A. false
B. true
9
Which of the following expression is equivalent to (x >
1).
A. !(x = 1)
B. x >= 1
C. !(x < 1)
D. !(x <= 1)
10
Analyze the following two code fragments.
(i)
int x = 5;
if (0 < x) && (x < 100)
System.out.println(“x is between 1 and 100”);
A. The second fragment has a syntax error.
B. The first fragment has a syntax error.
C. Both fragments produce the same output.
D. Both fragments compile, but produce different results.
11
Analyze the following code.
int x = 0;
int y = ((x < 100) && (x > 0)) ? 1: -1;