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