CSE143 – Miniquiz #7

02/06/2003

 

Name:

 

Section:

 

Directions: Answer the following questions.

 

Questions

1) Rate each of the following error checking and handling procedures as being either aggressive (A) or conservative (C):

 

  1. Use of assert.
  2. Fail-safe recovery.
  3. Comments and documentation.
  4. Frequent, and possibly redundant, invariant checking.
  5. Write to system logs.
  6. Raise exceptions.

 

2) Which of the following are true?

 

  1. Data invariants often hold true over an extended portion of a program.
  2. Assuming that some loop body executes n consecutive times, after the first execution of this loop body, loop invariants may or may not be true on executions 2àn of the loop body.
  3. A class invariant might not hold temporarily while an object is being constructed.
  4. Class invariants must always be true by the time a constructor or method terminates.

 

3) Which of the following statements are true?

 

  1. An Iterator provides access to elements of any collection one-by-one, even if the collection has no natural ordering.
  2. Asserts cannot be disabled without removing them from the source code.
  3. Asserts help code to crash early.
  4. All invariants can be expressed by simple Boolean conditions.