Tino APCS

The Difference Between Objects and Classes

An object is very closely associated with the class to which it belongs. An object has attributes as defined by its class. An object’s behavior is restricted by the methods that are included in its class. However, there are significant differences between objects and classes.

A class:

  • is a blueprint that defines attributes and methods.
  • cannot be altered during the program's runtime.
  • should begin with a capital letter.

An object:

  • is an instance of a certain class. (This is the most critical piece.)
  • exists during a program's runtime only.
  • must be explicitly declared and constructed within a program.
  • has attributes that can change in value and methods that can execute during program execution.
  • is referenced using an identifier, which should begin with a lowercase letter.

In a nutshell, classes are the blueprints for objects. Each class, or blueprint, is designed to produce many objects, all of a single type.

On the other hand, each object belongs to a single class. The myPencil object that was created earlier belongs to the DrawingTool class; myPencil, therefore, is the same type as all other objects created from DrawingTool, and can perform all of the methods a DrawingTool can. On that front, it cannot call methods from or hold attributes defined in the Math class, for obvious reasons.

Dark Mode

Outline