390 APPENDIX A: Introduction to Java
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
- package apress.appendix_A
- public class ClassA {
- // Instance methods
- public void method1() {
- System.out.println(" classA - method1");
- }
- private void method2() {
- System.out.println(" classA - method2");
- }
- // Static methods
- public static void method3() {
- System.out.println(" classA - method3");
- }
- }
Figure A-1. Parent-child relationship. ClassB extends ClassA