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