Goal:
Understanding Contracts
Problem 1:
Consider the Java 8
Iterator
interface.
-
For each method, identify all preconditions and postconditions.
Pay special attention to possible exceptions.
(Feel free to ignore the
forEachRemaining
method.)
-
For each precondition, identify a specific input that violates the precondition.
-
What "happens" if the precondition is violated? You should answer this
question both theoretically and practically. (Hint: Really, it's the same answer...)
-
For each postcondition, identify an input specific to that postcondition.