What is the result(Serializable)? : Questions « File « SCJP






import java.io.*;

class Keyboard {
}

public class MainClass implements Serializable {
  private Keyboard k = new Keyboard();

  public static void main(String[] args) {
    MainClass c = new MainClass();
    c.storeIt(c);
  }

  void storeIt(MainClass c) {
    try {
      ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("myFile"));
      os.writeObject(c);
      os.close();
      System.out.println("done");
    } catch (Exception x) {
      x.printStackTrace();
      
    }
  }
}








9.6.Questions
9.6.1.I/O Filters are supported on input, but not on output(True/False).
9.6.2.Answer: I/O filter
9.6.3.I/O Filters are supported by the InputStream/OutputStream class hierarchy, but not by the Reader/Writer class hierarchy(True/False).
9.6.4.Answer: I/O Filters and InputStream/OutputStream
9.6.5.I/O Filters read from one stream and write to another(True/False).
9.6.6.Answer: I/O filter and stream
9.6.7.A I/O filter may alter data that is read from one stream and written to another.
9.6.8.Answer: Altering data and I/O filter
9.6.9.The Serializable interface is used to identify objects that may be written to an output stream(True/False).
9.6.10.Answer: Serializable interface
9.6.11.Externalizable interface is implemented to control the way in which their objects are serialized.
9.6.12.Answer: Externalizable interface
9.6.13.The Serializable interface extends the Externalizable interface(True/False).
9.6.14.Answer: Serializable interface and the Externalizable interface
9.6.15.A File object can be used to change the current working directory(True/False).
9.6.16.Answer: File object
9.6.17.A File object can be used to access the files in the current working directory(True/False).
9.6.18.Answer: Current working directory
9.6.19.When a File object is created, a corresponding directory or file is created in the local file system(True/False).
9.6.20.Answer: File object and file system
9.6.21.File objects are used to access files and directories on the local file system(True/False).
9.6.22.Answer: File object and local file system
9.6.23.File objects can be garbage collected(True/False).
9.6.24.Answer: file object and garbage collection
9.6.25.When a File object is garbage collected, the corresponding file or directory is deleted(True/False).
9.6.26.Answer: file object, garbage collection and local file system
9.6.27.What output is displayed by the following program(StringReader)?
9.6.28.Answer: StringReader
9.6.29.What output is displayed by the following program?
9.6.30.Answer: RandomAccessFile
9.6.31.Writer classes can be used to write characters to output streams using different character encodings(True/False).
9.6.32.Answer: Writer classes
9.6.33.Writer classes can be used to write Unicode characters to output streams(True/False)
9.6.34.Answer: Writer classes and Unicode characters
9.6.35.Writer classes are character-oriented and do not support other primitive types or objects(True/False).
9.6.36.Answer: Writer classes and character-oriented
9.6.37.What is the result(regex)?
9.6.38.Answer: regex
9.6.39.What is the result(ObjectOutputStream)?
9.6.40.Answer: ObjectOutputStream
9.6.41.What is the output(long, Integer and equals)?
9.6.42.Answer: long, Integer and equals
9.6.43.What is the result(Serializable)?
9.6.44.Answer: Serializable
9.6.45.What is the output(transient variables)?
9.6.46.Answer: transient variables
9.6.47.What is the output(compare strings)?
9.6.48.Answer: compare strings
9.6.49.What is the result(reading with FileReader)?
9.6.50.Answer: reading with FileReader