Home Tutorial Java Scjp Part11 SCJP Module-11 Question-1

 
 

Share on Google+Share on Google+
SCJP Module-11 Question-1
Posted on: July 17, 2010 at 12:00 AM
Advertisement
The sample code will examine your knowledge FileOutputStream, ObjectOutputStream and how these classes are used to printing out data from the file.

Given a sample code:

import java.io.*;

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

public static void main(String[] args) {
Test f = new Test();
try {
FileOutputStream fs = new FileOutputStream("serializable.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(f);
os.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

What will be result of above program when compiled and run?

(A) An instance of Test is serialized.
(B) Compile time error. 
(C) Compile and run successfully but not serialized.
(D) An exception is thrown at runtime.

Answer:

(A)

Advertisement

Related Tags for SCJP Module-11 Question-1:


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.

Posted on: July 17, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com