LECTURE NOTES 29 NOVEMBER 2004 ASSIGNMENTS Wed 12/1 Assignment 5 Design Fri 12/3 CodeLab #12 Wed 12/15 Assignment 5 Code INHERITANCE AND CONSTRUCTORS What? - inheriting constructors How? - never occurs What? - defining a constructor for a subclass How? - define manually - compiler will define default iff you don't define any What? - meaning of constructor in an inheritance hierarchy - subclass is a specialization of the superclass - means logically must create the inherited part and the specialized part Why? - every subclass includes a call to the constructor of its superclass How? - use the super() method What? - default constructor public () { super(); } When? - you define a subclass constructor without a call to super What? - compiler automatically adds call to super as the first line of your constructor When? - no explicit inheritance What? - default superclass is Object What? - choosing a specific superclass constructor How? - pass arguments, ensuring that a constructor with those types exists When? - define a class with at least one explicit constructor - all explicit constructors take arguments - subclasses don't explicitly call super What? - implicit call to super does not pass arguments - no such super constructor exists - causes a compiler error What? - avoiding constructor errors How? - never rely on default constructors ABSTRACT SUPERCLASSES AND ABSTRACT METHODS Why? - sometimes doesn't make sense for the class to be instantiable - logical - semantic What? - abstract class How? 1. declare the class with the abstract modifier abstract class {...} 2. ensure the class includes at least one abstract method What? - *abstract method* How? 1. declare the method with the keyword abstract abstract ( abstract (