An object must implement the Serializable or Externalizable interface before it can be written to a stream asan object.