Welcome Guest | Sign in | Register
File - Discussion Page For Q.2706 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > File > Questions and Answers

Q: public class A {}
public class B implements Serializable {
A a = new A();
public static void main(String... args){
B b = new B();
try{
FileOutputStream fs = new FileOutputStream("b.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(b);
os.close();
}catch(Exception e){
e.printStackTrace();
}
}
}

What is the output for the above code ?
A. Compilation Fail B. java.io.NotSerializableException: Because class A is not Serializable.
C. No Exception D. None of the above

Answer and Explanation

Answer:java.io.NotSerializableException: Because class A is not Serializable.

Explanation:
java.io.NotSerializableException:A Because class A is not Serializable.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.