import java.io * ;
class DeserializationTest
{
public static void main(String[] args)
{
studentinfo si=null ; try
{
FileInputStream fis = new FileInputStream("student.ser"); ObjectOutputStream ois = new ObjectOutputStream(fis); si = (studentinfo)ois.readObject();
}
catch (Exception e)
{
e.printStackTrace(); } System.out.println(si.name); System.out. println(si.rid); System.out.println(si.contact);
}
}
Output:
Abhi
104
Null
Contact field is null because, it was marked as static and as we have discussed earlier static fields does not get serialized.
NOTE: Static members are never serialized because they are connected to class not object of class.