The super KeywordIn addition to its own nonstatic fields, a subclass must also ensure that any inherited nonstatic fields are initialized . This can be achieved by having a subclass constructor first scall a superclass constructor using the super keyword, followed by any arguments needed for the superclass constructor ” super(arguments); The superclass constructor call must be the first executable statement in the subclass constructor. If a superclass constructor is not explicitly called, the system will call the no-argument (default) superclass constructor. The super keyword can also be used to access superclass data or function members . Example: Using the super KeywordFor an example of calling a superclass constructor, look at the IonizedSpecies class from the "Inheritance Basics" example earlier in this chapter. For an example of calling a superclass method, see the "Method Overriding" section of Chapter 9. |