Characteristics of Objects

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

What makes an object?

Answer:

Here is my unofficial list:

  • An object is made of tangible material (the pen is made of plastic, metal, ink).
  • An object holds together as a single whole (the whole pen, not a fog).
  • An object has properties (the color of the pen, where it is, how thick it writes...).
  • An object can do things and can have things done to it.

Characteristics of Objects

The first item in this list is too restrictive. For example, you can think of your bank account as an object, but it is not made of material. (Although you and the bank may use paper and other material in keeping track of your account, your account exists independently of this material.) Although it is not material your account has properties (a balance, an interest rate, an owner) and you can do things to it (deposit money, cancel it) and it can do things (charge for transcactions, appreciate interest).

The last three items on the list seem clear enough. In fact, they have names:

  • An object has identity (it acts as a single whole).
  • An object has state (it has various properties, which might change).
  • An object has behavior (it can do things and can have things done to it).

This is a somewhat ordinary description of what an object is like. (This list comes from the book Object-oriented Analysis and Design, by Grady Booch, Addison-Wesley, 1994.) Do not be surprised if other notes and books have a different list. When you start writing object-oriented software you will find that this list will help you decide what your objects should be.

QUESTION 3:

can of tennis balls

Consider a tube of four yellow tennis balls.

  • Is the tube of tennis balls an object?
  • Is each tennis ball an object?
  • Could the top two balls be considered a single object?
  • Is the color of the balls an object?
  • Is your understanding of tennis balls an object?