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

 
 

SCJP Module-11 Question-1
Posted on: July 17, 2010 at 12:00 AM
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)

Related Tags for SCJP Module-11 Question-1:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.