The Sample example given below will test your understanding about the FileOutputStream class.
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);
(A)