public class Child4 extends Parent2
1: /*
2: * Part of a series of Child classes.
3: *
4: * Simple example of inheritance
5: * Child4 has all Parent methods
6: * also has own method sayValue
7: * also has its own constructor
8: * which uses Parent's constructor
9: *
10: * @author Mark Young (A00000000)
11: */
12: public class Child4 extends Parent2 {
14: /**
15: * Create this child with value and number.
16: *
17: * @param reqValue the requested value (in Parent)
18: */
19: public Child4(String reqValue) {
20: // create my Parent2 part using the value I was given
21: super(reqValue);
23: // if there were more fields to initialize,
24: // they'd be initialized down here
25: }
27: /**
28: * Report this child's value.
29: */
30: public void sayValue() {
31: // I have a getValue method! I inherited it.
32: System.out.println("My value is " + this.getValue());
33: }
35: }