Java Reference
In-Depth Information
Figure A-1. Parent-child relationship. ClassB extends ClassA
Listing A-15 illustrates how Figure A-1 could be implemented in code. It illustrates implementation
inheritance using the keyword extends in line 26.
Listing A-15 . Implementation Inheritance
1. package apress.appendix_A
2.
3. public class ClassA {
4.
5. // Instance methods
6. public void method1() {
7. System.out.println(" classA - method1");
8.
9. }
10.
11. private void method2() {
12. System.out.println(" classA - method2");
13.
14. }
15.
16. // Static methods
17. public static void method3() {
18. System.out.println(" classA - method3");
19.
20. }
21.
22. }
Search WWH ::




Custom Search