[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

JAVA Programming :: Exception Handling - Discussion

Home > JAVA Programming > Exception Handling > MCQs Questions Discussion

5 / 4

Choose the correct option.

What is the output for the below code ?

public class A {}
public class B implements Serializable {
private static 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();
}
}
}

ACompilation Fail

Bjavio.NotSerializableException: Because class A is not Serializable.

CNo Exception at Runtime

DNone of the above

Answer: Option (Login/Signup)

Show Explanation

Asked In ::

Post Your Answer Here:     

No Discussion on this question yet!