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. 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.