• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Serialization  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one query like,

#1) what happen If (Myclass Extends SuperClass implements java.io.serializable),
a) what effect will be happen for the variables of SuperClass?
2) Will the variables of superClass serialized??? or Not? Why?


Class SuperClass{

}

Class BaseClass extends SuperClass implements java.io.serializable {


}



#2) Class SuperClass implements java.io.serializable{

}

Class BaseClass extends SuperClass{


}

What happen BaseClass variable? Will they serialized?


My intension to know is,

1) what happen base class, if super class is serialized
2) if serialized class extends other class. Will the otehrclass serialized?


Thanks
Uday

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UdayK Kumar wrote:#1) what happen If (Myclass Extends SuperClass implements java.io.serializable),
a) what effect will be happen for the variables of SuperClass?
2) Will the variables of superClass serialized??? or Not? Why?



when you serialize MyClass the members of SuperClass will not be serialized. further, when you deserialize the MyClass the constructor of SuperClass will run!


UdayK Kumar wrote:what happen base class, if super class is serialized
2) if serialized class extends other class. Will the otehrclass serialized?



when a class inherits from an serializable class also the inherited class will be serializable. so, when you serialize MyClass the members of SuperClass will also be serialized. further, when you deserialize the MyClass the constructor of SuperClass will not run!




 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code. It will highlight your code and make it much easier to read.
It probably will also increase the number of people helping you. You can edit your post with the button.

About your questions:
What happened when you tried it?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!