1) The ________ statement is used to make simple decisions in Java. |
d) if |
2) A Boolean expression is one that is either: |
a) true or false |
3) This type of operator determines whether a specific relationship exists between two values: |
d) relational |
4) Which of the following expressions will determine whether x is less than or equal to y? |
c) x<=y |
5) Which one of the following is the not equal operator? |
d) != |
6) What will be the value of x after the following code is executed? |
b) 15 |
7) What will be the value of ans after the following code has been executed? |
b) 120 |
8) What will be the value of ans after the following code has been executed? |
c) 20 |
9) A block of code is enclosed in a set of: |
a) braces { } |
10) A flag may have the values: |
c) true or false |
11) If chr is a character variable, which of the following if statements is written correctly? |
d) if *chr == 'a') |
12) In Java, when a character is stored in memory, it is actually stored as a(n): |
A) unicode number |
13) This is an international coding system that is extensive enough to represent all the characters of all the |
b) unicode |
14) What will be the values of ans, x, and y after the following statements are executed? |
b) ans = 60, x= 0, y=50 |
15) What will be the value of bonus after the following code is executed? |
d) 1000 |
16) In most editors, you are indenting by one level each time that you press this key: |
A) tab |
17) If you prematurely terminate an if statement with a semicolon, the compiler will: |
C) all of the above |
18) What would be the value of bonus after the following statements are executed? |
c) 25 |
What would be the value of bonus after the following statements are executed? |
d) 1000 |
20) Which of the following is the correct boolean expression to test for: int x being a value between, |
c ((x> 500 && x < 650)) || (y !=1000)) |
21) ________ works like this: If the expression on the left side of the && operator is false, the expression |
a) short-circuit evaluation |
22) If str1 and str2 are both Strings, which of the following will correctly test to determine whether |
C) 3 |
23) To do a case insensitive compare which of the following could be used to test the equality of two |
D) a and b |
24) What will be the value of pay after the following statements are executed? |
D) 475.00 |
25) What would be the value of x after the following statements were executed? |
B) 20 |
26) What will be printed when the following code is executed? |
C) 45,678.26 |
27) Which of the following will format 12.78 to display as 12.8%? |
D) System,out.printf("%1f%%", 12.78); |
28) The expression tested by an if statement must evaluate to: |
c) true or false |
29) These operators use two operands: |
B) binary |
30) What is the value of x after the following code has been executed? |
D) 165 |
31) What is the value of ans after the following code has been executed? |
D) no value, this is a syntax error. |
32) What is the value of ans after the following code has been executed? |
B) 100 |
33) Enclosing a group of statements inside a set of braces creates a: |
A) block of statements |
34) This is a boolean variable that signals when some condition exists in the program: |
C) flag |
35) Which of the following correctly tests the char variable chr to determine whether it is NOT equal to |
C) if (chr != 'B') |
36) In an if/else statement, if the boolean expression is false: |
B) the statements or block following the else is executed |
37) What will be the values of ans, x, and y after the following statements are executed? |
c) ans = 35, x = 15, y = 40 |
38) What would be the value of discountRate after the following statements are executed? |
D) 0.0 |
39) What would be the value of discountRate after the following statements are executed? |
C) .01 |
40) What would be the value of discountRate after the following statements are executed? |
B) .04 |
41) Which of the following is the correct boolean expression to test for: int x being a value less than or |
D) ((x <= 500 || x > 650) && !(y ==1000)) |
42) If str1 and str2 are both Strings, which of the following expressions will correctly determine |
D) 2 and 3 |
43) What will be printed when the following code is executed? |
D) x is unknown when the last statement is executed |
44) The switch statement is a: |
A) multiple alternative decision structure |
45) What will be the value of charges after the following code is executed? |
C) 21.00 |
46) What would be the value of discountRate after the following statements are executed? |
D0 0.0 |
47) What will be printed when the following code is executed? |
D) 45,678.3 |
48) Which of the following will format 12.7801 to display as $12.78? |
System.out.printf("$%,.2f", 12.7801); |
49) What does the following code display? |
B) 9 12 |
50) What does the following code display? |
D) 12.38 |
T/F: Programs never need more than one path of execution. |
FALSE |
T/F: An important style rule you should adopt for writing if statements is to write the conditionally |
TRUE |
T/F: The if/else statement will execute one group of statements if its boolean expression is true or |
TRUE |
T/F: Because the && operator performs short-circuit evaluation, your boolean expression will usually |
True |
T/F: A local variable's scope always ends at the closing brace of the block of code in which it is declared. |
True |
T/F: When testing for character values, the switch statement does not test for the case of the character |
False |
T/F: An important style rule you should follow when writing if statements is to line up the conditionally |
False |
T/F: Unicode is an international encoding system that is extensive enough to represent ALL the characters |
true |
T/F: Because the || operator performs short-circuit evaluation, your boolean expression will generally be |
True |
T/F: When two Strings are compared using the compareTo method, the cases of the two strings are not |
False |
T/F: In a switch statement, each of the case values must be unique. |
True |
T/F: In a switch statement, if two different values for the CaseExpression would result in the same code |
False |
T/F: The String.format method works exactly like the System.out.printf method, except that it |
True |
T/F: The System.out.printf method formats a string and displays it in the console window. |
True |