多做题,通过考试没问题!

Java认证考试

睦霖题库>其他计算机考试>Java认证考试

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
答案解析:
进入题库查看解析

微信扫一扫手机做题