The Loan class given in the text does not implement java.io.Serializable. Analyze the following code.
```
public class Foo implements java.io.Serializable {
private int v1;
private static double v2;
private Loan v3 = new Loan();
}
```
a. An instance of Foo can be serialized because Foo implements Serializable.
b. An instance of Foo cannot be serialized because Foo contains a non-serializable instance variable v3.
c. If you mark v3 as transient, an instance of Foo is serializable.
Key:bc An object may not be serialized even though its class implements java.io.Serializable, because it may contain non-serializable instance variables.
b. An instance of Foo cannot be serialized because Foo contains a non-serializable instance variable v3.
c. If you mark v3 as transient, an instance of Foo is serializable.
An object may not be serialized even though its class implements java.io.Serializable, because it may contain non-serializable instance variables.
You might also like to view...
A kilobyte contains approximately one ________ bytes of data
A) hundred B) thousand C) million D) billion
The destructor for a class is called
a. explicitly from the main program b. when the class is instantiated c. when the object of the class goes out of scope d. Only at the end of main