IAT 167 Lecture Notes - Lecture 6: New Class

76 views3 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents