code:
class Dog implements Serializable {
private int dogSize;
public Dog(int size)
{
dogSize = size;
}
}
class Collar
{
private int collarSize;
public Collar(int size) { collarSize = size; }
public int getCollarSize() { return collarSize; }
}
public class SerializeDog {
public static void main(String [] args) {
Dog d = new Dog(5);}
// here the Collar class is non serializable, and its private instance variables are not being used by the serializable dog object... and there is no inheritance also and nothing has been declared transient... so after de-serialization the Collar class variables will be reinitialized to their default values.... is this right.. or will there be a compilation error...(as the non serializable class has no link with the serialized object dog and there in no inheritance also)
There is no HAS-A relationship between dog and collar... nor there is a IS-A relationship...
Will it still give a compilation error... or will it run...???