SWE/CS 332 In Class Exercise # 22
November 13, 2017

Name(s):

public class Super {
   public Super() {
      overrideMe();
   }
}
   public void overrideMe () {
   }
}
public final class Sub extends Super {

   private final Date date;  // filled in by constructor

   public Sub() {
      date = new Date();
   }
   @Override public void overrideMe () {
       System.out.println(date);
   }

   public static void main (String[] args) {
      Sub sub = new Sub();
      sub.overrideMe();
   }
}
  1. What is the pattern, and how common is it?

  2. What does the main method do, and why?

  3. Which of Bloch's rules does this example break?

  4. What does this example mean for Cloneable interface and the clone() method?

  5. What does this example mean for Serializable interface and the readObject() method?

  6. To what extent does this rule generalize to producer methods?