tag:blogger.com,1999:blog-8712770457197348465.post7564870217111224603..comments2024-03-17T23:01:26.872-07:00Comments on Javarevisited: Top 10 Java Serialization Interview Questions and Answers javin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger58125tag:blogger.com,1999:blog-8712770457197348465.post-6282791386336531782020-03-18T08:02:43.104-07:002020-03-18T08:02:43.104-07:00@Unknown, you mean static final variable or just f...@Unknown, you mean static final variable or just final variable? javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-14714087925281237192020-03-18T00:40:41.550-07:002020-03-18T00:40:41.550-07:00in question number 13 final variable also doesnt t...in question number 13 final variable also doesnt take part in serialization.Anonymoushttps://www.blogger.com/profile/15271148093510557260noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-41235244956753489142018-10-29T23:13:44.169-07:002018-10-29T23:13:44.169-07:00when we save a object in the database thus seriali...when we save a object in the database thus serialization happened or not , if yes then when it actually happened ? Anonymoushttps://www.blogger.com/profile/05382525596716377061noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-63637211055420902082017-06-10T13:00:28.931-07:002017-06-10T13:00:28.931-07:00Question 6) I see that if class A and C implement ...Question 6) I see that if class A and C implement Serializable and class B does not, where C extends B and B extends A. When I deserialize, all variables from A, B and C are deserialized instead of calling constructor of A and B.Sheena Aggarwalnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-73502880319168010872017-03-31T08:16:06.202-07:002017-03-31T08:16:06.202-07:00Great post Great post Anonymoushttps://www.blogger.com/profile/09316522864862129634noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-5531577987047983082017-02-26T06:09:04.122-08:002017-02-26T06:09:04.122-08:00Question 7) Can you Customize Serialization proces...Question 7) Can you Customize Serialization process or can you override default Serialization process in Java?<br />In this question number 7, your ans is yes but <br /> syntax for writeObjec is<br />public final void writeObject(Object obj) throws IOException <br />with final keyword,how can we override these method if it is declared with final keyword? Anonymoushttps://www.blogger.com/profile/05904402920991889504noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-69910989742888386802016-06-29T02:57:24.770-07:002016-06-29T02:57:24.770-07:00Hi,
I was asked recently why Serializable cannot ...Hi, <br />I was asked recently why Serializable cannot be a variable why have an empty interface which does nothing. I understand Polymorphic aspect but apart from that is there any other reason. Like you yourself said why Serializable cannot be replace with @serializable annotation ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-16963850266127773832016-03-29T06:55:54.598-07:002016-03-29T06:55:54.598-07:00@Anonymous, check the timezone of application and ...@Anonymous, check the timezone of application and Linux Server, they should be same but looks they are notjavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-42921698450140605772016-03-29T05:43:57.786-07:002016-03-29T05:43:57.786-07:00Hello sir,
I got date problem when i...Hello sir,<br /> I got date problem when i'm going to deploy application in Linux server and i have to changed the linux server system time also. but it takes wrong date. can you tell me how to resolve this problem. Problem is... if select date from datepicker 29-03-2016 but server side takes 28-03-2016..<br /><br /> Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2871587716266644582016-02-22T09:32:33.218-08:002016-02-22T09:32:33.218-08:00Why java allows only Byte Stream data in Serializa...Why java allows only Byte Stream data in Serialization process why not String.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-55256991173061874272016-01-19T04:28:10.363-08:002016-01-19T04:28:10.363-08:00@MetaMorphosis, sure, will write about readResolve...@MetaMorphosis, sure, will write about readResolve() and writeReplace(). One example which comes top of my mind is they are used to keep Singleton as Singleton i.e. just one instance during Serialization process. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-13119854009894069972016-01-18T22:25:45.275-08:002016-01-18T22:25:45.275-08:00@Javin : Very helpful post. Could you please add s...@Javin : Very helpful post. Could you please add some information on the following topics ?<br />1. readObjectNoData()<br />2. readResolve()<br />3. writeReplace()<br />4. Why collections implement Serializable ?<br /><br />Thanks !MetaMorphosishttps://www.blogger.com/profile/18264897930977956670noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2662288431762390742015-12-03T01:23:35.611-08:002015-12-03T01:23:35.611-08:00Regarding Question no 8: Java serialization proces...Regarding Question no 8: Java serialization process only continues in object hierarchy till the class is Serializable i.e. implements Serializable interface in Java and values of the instance variables inherited from super class will be initialized by calling constructor of Non-Serializable Super class during deserialization process. Once the constructor chaining will started it wouldn't be Anonymoushttps://www.blogger.com/profile/18013936546852981580noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9892797523875802772015-10-21T19:34:58.893-07:002015-10-21T19:34:58.893-07:00Great list of Java serialization questions, for mo...Great list of Java serialization questions, for more Java Serialization interview questions from last 5 years, see this list of <a href="http://javarevisited.blogspot.com/2015/10/133-java-interview-questions-answers-from-last-5-years.html" rel="nofollow">133 Java interview questions</a>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90702712153254575642015-10-04T09:08:21.057-07:002015-10-04T09:08:21.057-07:00How String object is read or write without using S...How String object is read or write without using Serializable interface.?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-7241919048503354762015-07-11T00:10:52.718-07:002015-07-11T00:10:52.718-07:00@Anonymous, Thanks for your comments.
You are cor...@Anonymous, Thanks for your comments.<br /><br />You are correct, You don't need to override readObject() from ObjectInputStream and writeObject() from ObjectOutputStream for serializing objects, but yes its confusing. <br /><br />Whole Serialization concept is little bit secret because JVM does most of the things without telling you directly. You mark your class as Serializable which is a javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-64252782972917277772015-07-10T04:08:04.083-07:002015-07-10T04:08:04.083-07:00Many People have asked that readObject() & wri...Many People have asked that readObject() & writeObject() are final methods from ObjectInputStream & ObjectOutputStream so how can we Override it?<br />The answer to that is, you are confused about Method Overriding.<br />First of all Our Class is never Extending neither ObjectInputStream, nor ObjectOutputStream, so it can't be called Overriding.<br />Check back with your Overriding Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-18487227266800851802015-04-13T00:12:35.364-07:002015-04-13T00:12:35.364-07:00This is regarding question 8. I tried this at HOME...This is regarding question 8. I tried this at HOME :) and serialization seems a special case. I had class B extend class A which was serializable while B wasnt. when I tried to serialize B I got the exception that B is not serializable, basically we dont need to implement any method specifically and throw NotSerializableException for scenario 8.<br />public class ParentA implements Serializable{<Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52643975288612991872014-11-16T06:02:16.747-08:002014-11-16T06:02:16.747-08:00Hi,
When you declared variable as transient that v...Hi,<br />When you declared variable as transient that variable will not serialize but how i can check whether particular variable is serialize or not.so that i can assure that variable not serialized when used with transient<br /><br />Thanks<br /><br /> Anonymoushttps://www.blogger.com/profile/16193263755644929420noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-76878429976388121682014-08-07T14:06:34.912-07:002014-08-07T14:06:34.912-07:00Can u pls explain Q6 in details?
If a class is Ser...Can u pls explain Q6 in details?<br />If a class is Serializable but its super class in not, what will be the state of the instance variables inherited from super class after deserialization?Anonymoushttps://www.blogger.com/profile/15742853181264298046noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-7168146218531655502014-06-18T10:04:33.363-07:002014-06-18T10:04:33.363-07:00Feeling great after reading this awesome & exh...Feeling great after reading this awesome & exhaustive list of questions on Serialization.....Many thanks :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-35004176473839276762014-05-27T04:16:36.617-07:002014-05-27T04:16:36.617-07:00Hi Sir,
Can we keep our subclass non-serializabl...Hi Sir,<br /><br /> Can we keep our subclass non-serializable if the super class implements Serializable ?<br />Please let me know.<br />Thanks in advance :)<br />Regards<br />Aman.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-57087573672186027412014-05-27T01:26:28.391-07:002014-05-27T01:26:28.391-07:002) class A{
a1;
a2;
a3
}
after serelization
class...2) class A{<br />a1;<br />a2;<br />a3<br />}<br /><br />after serelization<br />class B{<br />a1;<br />a2;<br />a3;<br />a4;<br />}<br />will it be possible<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-33199120107491042302014-03-10T22:30:47.066-07:002014-03-10T22:30:47.066-07:00Hi Javin:
A very nice blog. keep it up and keep a...Hi Javin:<br /><br />A very nice blog. keep it up and keep adding more. Follow-up questions (comments) are also very educative.<br /><br />bye,Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6830018761312451762014-02-23T05:33:32.737-08:002014-02-23T05:33:32.737-08:00For transient field, its the default value of the ...For transient field, its the default value of the data type, for Object type it would be null.<br />For static field, the value would be the same as defined.Alpshttps://www.blogger.com/profile/02236090103807493232noreply@blogger.com