SCJP Certification

Sun Certified Java Programmer Certification exam essentials

October 5th, 2009

What will be the output of the following code?

Java Facts, by Daisy Williams.

import java.io.*;
class ABC implements Serializable { }
public class SerializeABC {
public static void main(String[] args) {
ABC ab = new ABC();
try {
FileOutputStream fs = newFileOutputStream(“testSer.ser”);
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(ab);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream(“testSer.ser”);
ObjectInputStream ois = new ObjectInputStream(fis);
ab = (ABC) ois.readObject();
ois.close();
} catch (Exception e) { e.printStackTrace(); }
}
}

Share

Back Top

Responses to “What will be the output of the following code?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*