
3.2 Creating Objects Using Constructors
A class describes a generic template for creating, or instantiating, objects. In
fact, an object must be instantiated before it can be used. To understand
how to instantiate an object of a class and how to call methods of the class,
you must know the API of a class, which the creators of the class make pub-
lic. Table 3.1 shows the API of the SimpleDate class, written by the authors
of this textbook.
Instantiating an object consists of defining an object reference—which will
hold the address of the object in memory—and calling a special method of
the class called a constructor, which has the same name as the class. ...