IAT 167 Lecture Notes - Lecture 6: New Class
Document Summary
Define a new class based on an existing class. New class inherits everything from the existing one. Inherit: subclass inherits fields and methods from its superclass, Extend: subclass define its own fields to extend functionality. Inheritance hierarchy: set of classes with different levels by is-a relationship. Superclass: general class that house the common properties and behaviours. Subclass/ child classes: more specific versions of the superclass super vs this. Super: keyword that refers to the superclass portion [refers to the superclass] This: keyword that refers to the current object [refers to the whole object] This. rating: refers to a field of the current object [to differentiate a field from a parameter] Super(arguments) [must be the first statement in child class constructor] Followed by signature of the parent class. Ability to create a variable/ method that has more than one form: overriding polymorphism. Subclass can redefine its parent method with the same signature. Overriding: redefining a method with the same signature.