Home Tutorial Java Scjp Part11 SCJP Module-11 Question-9

 
 

SCJP Module-11 Question-9
Posted on: July 20, 2010 at 12:00 AM
Advertisement
The Sample example given below will test your understanding about the Stream classes in Java.

Given a sample code:

class Big {
int value = 77;

Big() {
value = 66;
}
}

public class Test extends Big implements Serializable {
private static final long serialVersionUID = 1L;

public static void main(String[] args) {
Test ts = new Test();
ts.value = 11;
try {
FileOutputStream fos = new FileOutputStream("savedata.ser");
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(ts);
os.close();
FileInputStream fs = new FileInputStream("savedata.ser");
ObjectInputStream is = new ObjectInputStream(fs);
Test ts2 = (Test) is.readObject();
System.out.print(ts2.value);
is.close();
} catch (Exception x) {
}}}

What will be the output when compiled and run?

(A) 0
(B) 11
(C) 66
(D) Compilation error

Answer:

(C)

Advertisement

Related Tags for SCJP Module-11 Question-9:


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.

Posted on: July 20, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com