> Education Commons > Java > Resources

Object-Oriented Programming

The goal of object-oriented programming (OOP) is to model some aspect of the real world like an enterprise (school, community organization, business) or process (air traffic control, course selection, oil refinement). The model is composed of objects (airplanes, students, raw and processed materials) and the rules which govern their interaction.

Barnes and Kölling (2012) offer these examples of objects: words and paragraphs in a word-processing program; users and messages in a social-networking system; monsters in a computer game (p. 3).


An object models an aspect of the real world:

Every object is an instance of a class. The relevant class declaration specifies what the class instance knows and can do.

A class declaration, in effect, creates a new datatype. This datatype may have multiple fields, and those fields may be of multiple different types. In addition, a class declaration specifies methods which operate on those fields.

The process of creating an instance is called instantiation.

Everything that an object knows is called the object’s state. An object’s state is stored in

The state of any one object is independent of the state of all other objects.

Objects will reveal their state in response to the invocation of a type of method called an accessor.

Objects will change their state in response to the invocation of a type of method called a mutator.

When we use another programmer’s classes, we don’t know how the class was implemented. (For example, we don’t know the number, names, or datatypes of its fields.) We do know the responsibilities of every object of that class: its knowing responsibilities and its doing responsibilities.

Every class is composed of a public interface and private implementation. The public interface describes the responsibilities of objects of that class; the interface is presented as Javadoc. The private implementation of another programmer’s class is of no concern to us.

Every programmer who makes a class available to to others is issuing a contract to those other programmers: if you respect the conditions specified in the Javadoc, the object will function as specified.


Barnes, D. & Kölling M. (2012). Objects first with Java: A practical introduction using BlueJ. Toronto: Pearson Education, Inc. ISBN 978-0-13-249266-9. > Education Commons > Java > Resources

[This page last updated 2020-12-23 at 12h13 Toronto local time.]