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
答案解析:有

微信扫一扫手机做题