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

 
 

SCJP Module-11 Question-8
Posted on: July 20, 2010 at 12:00 AM
The Sample example given below will test your understanding about the FileOutputStream class.

Given a sample code:

1    import java.io.*;

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);

Answer:

(A)

Related Tags for SCJP Module-11 Question-8:


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.