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();
}
}
-
What is the pattern, and how common is it?
-
What does the main method do, and why?
-
Which of Bloch's rules does this example break?
-
What does this example mean for
Cloneable
interface
and the
clone()
method?
-
What does this example mean for
Serializable
interface
and the
readObject()
method?
-
To what extent does this rule generalize to producer methods?