posted 12 years ago
Please refer the below program:
Output:
Please help me to understand the lines 53 and 61
I have implemented the writeObject() and readObject() methods for the Dog class. The
line 53: I am passing the Dog object to writeObject() method. So it could somehow use the Dog reference and get access to the writeObject() that is overridden.
line 61: I am using the ObjectInputStream reference variable to call the readObject() method. I am casting it to Dog after the object is returned by readObject method.
How could the ObjectInputStream reference variable get access to a method that is available in Dog class. I am not passing the dog object as an argument to readObject.
Could someone help to understand the ObjectInputStream gets access to Dog's readObject() method.
Thanks
Loganathan