Question: 1) The switch instruction is a more general-purpose (more versatile) tool than the if instruction. True False 2) You are writing a program that will
1) The switch instruction is a more general-purpose (more versatile) tool than the if instruction.
2) You are writing a program that will allow a user to enter a single word identifying her 'sign' in the Chinese zodiac (e.g. "Dog") and then show some information about that sign. Obviously a decision must be made in this program. Which selection structure(s) could you use?
| a) | if statements should be used |
| b) | a switch statement should be used |
| c) | either if statements or a switch statement could be used |
3) What numerical value for x will cause the following expression to evaluate to true. x > 5 || x < 9
| d) | NO value of x -- all numerical values cause the expression to evaluate to false |
| e) | ALL numerical values cause the expression to evaluate to true |
| 4) Which of the following is a legal Java expression? | |
| 5) Which of the following operators has the highest precedence? | |
| | 6) Which of the following is true in Java? I. Every else must have a preceding if. II. Every if must have a following else. |
| | 7) What kind of loop is a data validation loop? |
8) Which loop control structure can NOT be used if there are conditions under which the body of the loop should be executed zero times?
| d) | Any of the loop control structures can be used in this situation. |
| e) | None of the above -- this situation is impossible to program. |
9) You know that a for loop is usually the best choice for a counting loop, but which other loop control structure(s) could possibly be used to create a counting loop?
| c) | any of the loop control structures can be used to create a counting loop |
| d) | none of the above -- only a for loop can be used |
10) Consider the following class definition:
public class Woog{
public static void main (String[] a){
Fiddle f = new Fiddle();
...
}
}
How would you describe the relationship between Fiddle and Woog?
| a) | Fiddle is the client class. Woog is the supplier class. |
| b) | Woog is the client class. Fiddle is the supplier class. |