试题详情
单项选择题 import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?() 

A、 Compilation fails.

B、 An exception is thrown at runtime.

C、 An instance of Forest is serialized.

D、 A instance of Forest and an instance of Tree are both serialized.

  • B
  • 关注下方微信公众号,在线模考后查看

热门试题