Share on Google+Share on Google+

SCJP Module-11 Question-3

The Sample code given below will test your understanding about the FileOutputStream and ObjectOutputStream in Java.

Given a sample code:


class Upper {

class Test implements Serializable {

Upper a = new Upper();

public static void main(String[] args) {
Test b = new Test();
try {
FileOutputStream fs = new FileOutputStream("file.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
} catch (Exception e) {

What will be result of above program when compiled and run?

(A) Fail to compile
(B) class Upper is not Serializable so it raise
(C) Compile and run sucessfully.
(D) An instance of Test is serialized.




Posted on: July 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.