Aqua Phoenix
     >>  Lectures >>  Java 1  


1.6 Objects - Definition

Objects are the manifestation or instantiation of classes. While classes provide a framework, i.e. variable names, method declarations, and general behavior, an object is a particular manifestation of a class. While there may only be one definition of a particular class X, there may be zero to many objects of that class.

For example, the word Car generally describes what an automobile is. Car is a Class. Crysler Concorde, Mercedes 600S, and Mitsubishi Eclipse are particular instantiations (examples) of cars - they generally follow the definition of a Car (tires, doors, engine, windshield, speed, mileage, etc.), and are thus manifestations of the Car. They are Objects.

Rules and Observations

  • An object can be instantiated from any other class. Since classes are public, it is possible to instantiate an object of that class anywhere in the code.
  • An object has state. It contains variables (defined in the class), but with particular values that are unique to this object.
  • An object has a location in memory.
  • An object is not a copy of a class or the code of the class. Class code exists only once, since it is the same across all objects of a given class. An object is merely the collection of variables that is different across objects.
  • A class can instantiate itself (see method main later)