IAT 167 Lecture Notes - Lecture 6: New Class

46 views3 pages

For unlimited access to Class Notes, a Class+ subscription is required.

Week 6
Inheritance
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
Single inheritance: only one parent class
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]
super.show() : calls superclass' method
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]
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class