ariejan (owner)

Revisions

gist: 44048 Download_button fork
public
Public Clone URL: git://gist.github.com/44048.git
Embed All Files: show embed
15.java #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.*;
 
public class TestSer {
  public static void main(String[] args) {
    SpecialSerial s = new SpecialSerial();
    try {
      ObjectOutputStream os = new ObjectOutputStream(
        new FileOutputStream("myFile"));
      os.writeObject(s); os.close();
 
      System.out.print(++s.z + " ");
      ObjectInputStream is = new ObjectInputStream(
        new FileInputStream("myFile"));
      SpecialSerial s2 = (SpecialSerial)is.readObject();
      is.close();
      System.out.println(s2.y + " " + s2.z);
    } catch (Exception x) {System.out.println("exc"); }
  }
}
 
class SpecialSerial implements Serializable {
  transient int y = 7;
  static int z = 9;
}
15.textile #

Which are true? (Choose all that apply.)

  • A. Compilation fails.
  • B. The output is 10 0 9
  • C. The output is 10 0 10
  • D. The output is 10 7 9
  • E. The output is 10 7 10
  • F. In order to alter the standard deserialization process you would override the readObject() method in SpecialSerial.
  • G. In order to alter the standard deserialization process you would override the defaultReadObject() method in SpecialSerial.