SWE/CS 332 In Class Exercise # 2


Name(s):

Goal: Understanding Contracts

Problem 1:
Consider the Java 8 Iterator interface.

  1. For each method, identify all preconditions and postconditions. Pay special attention to possible exceptions.


  2. For each precondition, identify a specific input that violates the precondition.


  3. What "happens" if the precondition is violated? You should answer this question both theoretically and practically. (Hint: Really, it's the same answer...)


  4. For each postcondition, identify an input specific to that postcondition.