When a program starts running there are no objects,
just class definitions and
a static main()
method.
Usually main()
then constructs
some objects and calls their
methods to do the work of the program.
In our example,
main()
constructed just one object and then called its
calculateMPG()
method.
The picture shows the variable car
in the static main()
method
referring to the object that has been constructed
following the plan given in the class definition of Car
.
The static main()
method is actually part of the
MilesPerGallon
class, which is not shown in the picture.