1. How does this serializability will be useful ?? I mean what are the practical aspects of serializability ??
Practical aspect of serializable is when you are using some variable of a class like dog in your case and you want to save the state of all the variables of class dog that so that what ever manipulations are done on dog object you have the original version saved with you. so now what you can do to for that is save that object and how do you do that in java it is done through use of Serializable interface so that when ever later on in the day you want to use that dog object which was initially created you can do that.
2. How do i use the Dog class in another code, so that serializability is applicable??
In some other class you will create an object of type dog and initialise all the other variables of that dog object. now when ever you want to serialize that dog object
to de serialize
3.What does defaultWriteObject() and defaultReadObject do? Please explain in detail!!
these are to make your serialization customizable
like in dog definition might be like this\
class dog implements Serializable
so now there might be a case that some objects defined in class dog are not serilzable (objects of other class are defined in class dog which do not implement serilzable) in that case you would like to customize the serilization the way you want to save the state of objects of a dog class .
for that scenario these two methods are provided which comes into picture in some other class serilize or deserilize objects of dog class these methods are automatically called .
I hope it clears your doubt about serilizable