Card 09/ 09
Recap: Classes and Objects
Classes, new, constructors, the default constructor, this and static, with where each was.
Classes and objects come down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
A class describes; new creates; a reference points | Classes and Objects: A Description and Its Instances |
A constructor is named for the class, declares no return type, and runs inside new | Java Constructors: Making an Object Valid From the Start |
Constructors are chosen by argument list, and this(...) chains them | Constructor Overloading Example: Two Ways to Create an Order |
| Writing any constructor removes the default no-argument one | The Default Constructor Disappears When You Write One |
static belongs to the class; instance members belong to one object | static vs Instance Members |
An object has its own copy of every instance field, and that is the only thing it has that the class does not. Everything else in this topic follows from asking which of the two something belongs to.
← → move through sections and cards