• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What restricts fields from Serialization

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class fields with the following modifiers will not be serialized
1)private
2)static
3)transient
4)protected
I think , Only transient..
Correct me..
Thanx
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think static and transient are correct answers.

Correct me if wrong.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when a class is loaded the static members are
intialized ( either to their default values or specified)
They are not instantiated when an instance of the
class is created .
Now if the static members do not belong to objects
then its very unlikely that they'll be saved as
as persistent members of objects.
Somebody plz correct me if I'm wrong

------------------
max
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree wid Angela n Tauqueer
Correct options r 2) & 3)
static members ( or class members ) do not belong to object
so they are not serialized
while de-serializing the object ,when da class is loaded for first time , static fields get there default value , or value assigned in static initializers
There is one more point to remember , instace variables will get there values back while de-serializing , but to make the instace of such a object , de-serializing process first calls its no-parameter constructor ( also knwon as default constructor )
steps r :
- call no-parameter constructor to allocate memory for an object
- read n fill in da values of instance variables of this object
this process can be recursive , as serialization can also be , if the object references contained by object's member variable are also serializable
So apart from implementing serializable interface , Class must also hav a no-parameter constructor , to lend itself for serialization process.
------------------
Gagan (/^_^\)
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just one more thing....
the question seem poorly worded to me


Class fields with the following modifiers will not be serialized
1)private
2)static
3)transient
4)protected


"Class fields" are those wid "static" modifier , thos which belong to class only ..no?
it shld better hav been "fields"
------------------
Gagan (/^_^\)
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx all.
Gagan,ya ,the question is poorly worded..It's from valiveru's test and it seem to have lot of errors...
Any errata..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic