The ObjectOutput
interface contains method writeObject, which takes an Object
as an argument and writes its information to an OutputStream
. A class that implements interface ObjectOutput
(such as ObjectOutputStream
) declares this method and ensures that the object being output implements interface Serializable
(discussed shortly). Correspondingly, the ObjectInput
interface contains method readObject, which reads and returns a reference to an Object
from an InputStream
. After an object has been read, its reference can be cast to the object’s actual type.