Share on Google+Share on Google+

SCJP Module-11 Question-8

The Sample example given below will test your understanding about the FileOutputStream class.

Given a sample code:

1    import*;

2    class Test implements Serializable {
3    private static final long serialVersionUID = 1L;

4    public static void main(String[] args) {
5    Test f = new Test();
6    try {
7    FileOutputStream fs = new FileOutputStream("serializable.ser");
8    // Place code here
9    os.writeObject(f);
10  os.close();
11  } catch (Exception ex) {
12  ex.printStackTrace();

What will be placed at line no 8 for successful serialization ?

(A) ObjectOutputStream os = new ObjectOutputStream(fs);
(B) New dataOutputStream(os);
(C) New dataOutputStream(new OutputStream(os));.
(D) DataOutputStream(os);




Posted on: July 20, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null