The Concept of Scope

Multiple objects can be instantiated from a single class. Each of these objects has its own identity and state. This is an important point. Each object is constructed separately and is allocated its own memory. However, some attributes and methods may be shared by all the objects instantiated from the same class, thus sharing the memory allocated for these class attributes and methods.

A Shared Method

A constructor is a good example of a method that is shared by all instances of a class.

Although methods generally represent the behaviors of an object, the state of the object is normally represented by attributes. There are three types of attributes:

  • Local attributes

  • Object attributes

  • Class attributes

Local Attributes

Local ...

Get Object-Oriented Thought Process, The, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.