This website is preserved for historical and scholarly reference and is no longer actively maintained.
QUIZ 11
September 18, 1998
1. In the code to process an Employee, the statement
emp = Employee.readIn ( );
occurs one or more times. In the following code indicate
clearly everywhere that this line should be placed.
Employee emp;
int hours;
while ( emp != null ) {
System.out.flush ( );
hours = Integer.parseInt (br.readLine ( ) );
System.out.println ( emp.calcPay ( hours ) );
}
For the answers to questions 2 and 3, select from the following list
of options:
for short-circuit break header
extreme continue iteration accumulator
2. The text says that a __________ statement "can be downright
dangerous, particularly when used in a while statement.
3. The text says of a __________ statement: "Although there may be
some occasions when using the ... statement is justified, we
caution beginning and intermediate programmers not to employ it."
4. Suppose we were defining a class that had several methods that
needed to calculate the value of one non-negative integer (x)
raised to the power of another non-negative integer (y).
Complete the helper method below.
private int power ( int x, int y ) {
// y >= 0 returns x^y