Term
Based on the code below:
int x = [???], y;
if (x > 5) y = 1; else if (x < 5) { if (x < 3) y = 2; else y = 3; } else y = 4;
What is the value of y if x = 6? Answer A. 3 B. 4 C. 2 D. 1 |
|
Definition
|
|
Term
The simplest statement you can use to make a decision is the ____ statement. Answer A. Boolean B. if C. this D. true false |
|
Definition
|
|
Term
The AND operator is written as two ___. Answer A. equal signs B. asterisks C. ampersands D. plus signs |
|
Definition
|
|
Term
A logical structure called ____ structure is when one step follows another unconditionally. Answer A. decision B. straight C. sequence D. unconditional |
|
Definition
|
|
Term
Suppose x is 5 and y is 7. What is the value of the following expression?
(x != 7) && (x <= y) Answer A. false B. true C. This is an invalid expression in Java. D. None of these |
|
Definition
|
|
Term
Suppose that num is an int variable. The statement num is less than 0 or num is greater than 50 in Java is written as: Answer A. num < 10 or num > 50 B. (num < 10) or (num > 50) C. num < 10 || num > 50 D. None of these |
|
Definition
|
|
Term
What is the output of the code below:
if (6 > 8) { System.out.println(" ** "); System.out.println("****"); } else if (9 == 4) System.out.println("***"); else System.out.println("*"); Answer A. *** B. **** C. * D. ** |
|
Definition
|
|
Term
What is the output of the following Java code?
int x = 55; int y = 5;
switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; }
System.out.println(y); Answer A. 2 B. 5 C. 8 D. None of these |
|
Definition
|
|
Term
In a ____ control structure, the computer executes particular statements depending on some condition(s). Answer A. sequence B. looping C. repetition D. selection |
|
Definition
|
|
Term
Based on the code below:
int x = [???]; int y = !(12 < 5 || 3 <= 5 && 3 > x) ? 7 : 9;
What is the value of y if x = 2? Answer A. 3 B. 7 C. 9 D. 2 |
|
Definition
|
|
Term
The conditional operator ?: takes _____ arguments. Answer A. 4 B. 5 C. 2 D. 3 |
|
Definition
|
|
Term
Based on the code below:
String str1 = "car"; String str2 = "cars"; String str3 = "cat"; String str4 = "can";
str2.compareTo(str1); //statement 1 str1.compareTo(str3); //statement 2 str3.compareTo(str4); //statement 3
the value of statement 1 is ____. Answer A. a boolean value B. a negative integer C. 0 D. a positive integer |
|
Definition
|
|