Skip to main content
ICT
Lesson A2 - Object Oriented Programming
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

E. The Difference Between Objects and Classes page 7 of 9

  1. 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.
  • is written by a programmer.
  • cannot be altered during program execution.
  • is named by a class name.

An object:

  • must belong to some class.
  • is an instance of that class.
  • exists during the time that a program executes.
  • must be explicitly declared and constructed by the executing program.
  • has attributes that can change in value and methods that can execute during program execution. (The class to which the object belongs defines theses attributes and methods.)
  • is most often referenced using an identifier.
  1. Classes can be compared to a blueprint. The purpose of a blueprint is to provide a guide for creating things, just as the purpose of a class is to guide the creation of objects. A single blueprint is designed to produce a single basic type of object. Similarly, the objects from the same class all share common characteristics.

  2. Each object must belong to one particular class, and the object is said to be a member of the class to which it belongs. The myPencil object that was created earlier belongs to the DrawingTool class. This means that the myPencil object is permitted to perform DrawingTool methods (operations). This also means that the myPencil object is not permitted to perform DrawSquare methods; these methods are designed for a different kind (class) of object.

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.