OOPortal OOPortal


User Defined Types  «Prev  Next»
Lesson 5 Objects are instances of classes
Objective Describe how Objects instantiate Classes

Describe how Objects instantiate Classes

A class defines a type. In general, there can be many different instances of the class, each of which may have different values for the attributes of the class. These instances are called objects. For example, the origin is a Point object whose x attribute is 0.0 and whose y attribute is 0.0. This can be represented by an object diagram.
Object diagrams are useful when giving examples of values for all the attributes or showing how an object changes as the system runs. An object diagram is deliberately similar to a class diagram. It is divided into two compartments, like this:
1 2
Origin Point
Mouse Out

Object Diagram Example


Occasionally, you will see diagrams for anonymous objects. These are objects for which no name is obvious or needed.
In the video store course example, objects of the Title class might include the Gone With the Wind title or the Bambi title. Objects of the Customer class might include "Jo Smith" Here's how that object might look:
Jo Smith: Customer
Name: Jo W. Smith
Address: 123 Main Street, Ourtown
Phone: 555-1212
Balance: 1.00