Fraction implements Serializable
.
Write a test that serializes and deserializes a Fraction
object; That is:
Create a Fraction
Create a ByteArrayOutputStream
Chain an ObjectOutputStream
to the ByteArrayOutputStream
Write the Fraction object onto the ObjectOutputStream
using writeObject()
Close the ObjectOutputStream
Get a byte array from the ByteArrayOutputStream
using toByteArray()
Make a ByteArrayInputStream
from the byte array
Chain an ObjectInputStream
to the ByteArrayInputStream
Read the object from the ObjectInputStream
using readObject()
Verify that the object is equal to but not the same as the original object