Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java Serialization

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Forget Steve. Look at this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic