Barclays Capital Interview Question
Software Engineer / DevelopersAssume the code compiles successfully,
Can any one tell , what will happen if a class contain a reference which does not implement Serializable interface ?
To be more precise, if a class contain a reference which does not implement Serializable interface and it is not null then only you will get a 'NotSerilizableExcetion' . To avoid this, transient modifier should be used against that reference.
In this question Thread reference is null so you won't get any runtime serialize exception.
Class won't compile, reasons:
- Anshuman April 05, 20101. String st='mansoor-shaikh'; //This should go into double quotes
2. String int = 90; //You can't use reserve keywords, here is "int". Second no quotes are there for String data type :)
Class can't be serialized
Reasons: Doesn't implement serializable interface.