Self-Review Exercises 2
Self-Review Exercises
4.1 Fill in the blanks in each of the following statements:
a) All programs can be written in terms of three types of control structures: ,
and .
b) The statement is used to execute one action when a condition is true and an-
other when that condition is false.
c) Repeating a set of instructions a specific number of times is called iteration.
d) When it’s not known in advance how many times a set of statements will be repeated,
a(n) value can be used to terminate the iteration.
e) The structure is built into Java; by default, statements execute in the order
they appear.
f) Instance variables of types char, byte, short, int, long, float and double are all given
the value by default.
g) If the increment operator is to a variable, first the variable is incremented by
1, then its new value is used in the expression.
h) When the declaration int y = 5; is followed by the assignment y += 3.3; the value of y
is .
4.2 State whether each of the following is true or false. If false, explain why.
a) An algorithm is a procedure for solving a problem in terms of the actions to execute and
the order in which they execute.
b) A set of statements contained within a pair of parentheses is called a block.
c) A selection statement repeats an action while a condition remains true.
d) A nested control statement appears in the body of another control statement.
e) Java provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for
abbreviating assignment expressions.
f) The primitive types (boolean, char, byte, short, int, long, float and double) are por-
table across only Windows platforms.
g) Specifying the order in which statements execute in a program is called program control.