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


Share on Google+Share on Google+
SCJP Module-11 Question-10
Posted on: July 20, 2010 at 12:00 AM
The Sample class given below will test your understanding about the Stream classes in Java.

Consider a sample code:

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

3    public static void main(String[] args) {
4    Test ts = new Test();
5    int value = 11;
6    try {
7    FileOutputStream fos = new FileOutputStream("savedata.ser");
8    ObjectOutputStream os = new ObjectOutputStream(fos);
9    os.writeObject(ts);
10    os.close();
11    // Place code here
12    ObjectInputStream is = new ObjectInputStream(fs);
13    Test ts2 = (Test) is.readObject();
14    System.out.print(ts2.value);
15    is.close();
16    } catch (Exception x) {

What will be placed at line no-15 for desirialization ?

(A) FileInputStream fs = new FileInputStream(new DataOutputStream("savedata.ser"));
(B) FileInputStream fs = new FileInputStream("savedata.ser");
(C) DataOutputStream("new FileInputStream("savedata.ser") ");
(D) DataOutputStream("savedata.ser");




Related Tags for SCJP Module-11 Question-10:

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 20, 2010

Recommend the tutorial

Advertisements Advertisements