Please enable JavaScript to use CodeHS

Chapter 5

Writing Classes

5.2 Constructors

State of an Object

The Constructor

No-Argument Constructor

SuperHero Class

Initializing an Object without a Constructor

Check Your Understanding

  1. Incorrect Correct No Answer was selected Invalid Answer

Exercise: Dog Class

Vocabulary

Term Definition
alias A variable that references an existing object. When the alias variable is manipulated, so is the original object, and vice versa.
“Has-a” Relationship Objects are defined by having the attributes, or instance variables that they are assigned.

Do you have feedback on this lesson? Let us know here
Rate this lesson:

Feedback on this lesson:

Issue found (optional):