Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given: import java.io.*; class Food {Food() { System.out.print(”1”); } } class Fruit extends Food implements Serializable { Fruit() { System.out.print(”2”); } } public class Banana2 extends Fruit { int size = 42; public static void main(String [] args) { Banana2 b = new Banana2(); b.serializeBanana2(b); // assume correct serialization b = b.deserializeBanana2(b); // assume correct System.out.println(” restored “+ b.size + “ “); } // more Banana2 methods } What is the result?()
- A、 Compilation fails.
- B、 1 restored 42
- C、 12 restored 42
- D、 121 restored 42
- E、 1212 restored 42
- F、 An exception is thrown at runtime.
正确答案:D
答案解析:有
微信扫一扫手机做题