问题详情

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.

时间:2022-01-02 03:50 关键词: SCJP程序员认证考试

答案解析

D
相关问题