public class Child2 extends Parent
1: /**
2: * One of a sequence of classes extending Parent. This class replaces the
3: * getValue method from Parent.
4: *
5: * Child2 has its own method
6: * sayValue
7: * also has all Parent methods
8: * but has replaced the Parent's getValue method
9: * with an entirely new one of its own
10: *
11: * @author Mark Young (A00000000)
12: */
13: public class Child2 extends Parent {
15: /**
16: * Report this child's value.
17: */
18: public void sayValue() {
19: // this method uses my own (specialized) getValue method
20: System.out.println("My value is " + this.getValue());
21: }
22:
23: /**
24: * Get my own value. Overrides getValue in Parent.
25: *
26: * @return a very babyish value
27: */
28: public String getValue() {
29: return "Ba-ba";
30: }
31: }