The java.io.ObjectOutputStream.writeObjectOverride(Object obj) method is used by subclasses to override the default writeObject method. This method is called by trusted subclasses of ObjectInputStream that constructed ObjectInputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final".
Following is the declaration for java.io.ObjectOutputStream.writeObjectOverride() method.
protected void writeObjectOverride(Object obj)
obj -- object to be written to the underlying stream
This method does not return a value.
IOException -- if there are I/O errors while writing to the underlying stream
The following example shows the usage of java.io.ObjectOutputStream.writeObjectOverride() method.
Let us compile and run the above program, this will produce the following result: