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):
- Use of
assert.
- Fail-safe
recovery.
- Comments
and documentation.
- Frequent,
and possibly redundant, invariant checking.
- Write
to system logs.
- Raise
exceptions.
2) Which of the following are true?
- Data
invariants often hold true over an extended portion of a program.
- 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.
- A
class invariant might not hold temporarily while an object is being
constructed.
- Class
invariants must always be true by the time a constructor or method
terminates.
3) Which of the following statements are true?
- An
Iterator provides access to elements of any collection one-by-one, even if
the collection has no natural ordering.
- Asserts
cannot be disabled without removing them from the source code.
- Asserts
help code to crash early.
- All
invariants can be expressed by simple Boolean conditions.