• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

transient and protected fields cannot be serialized ?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question)Class fields with the following modifiers will not be serialized
a)private,
b)static,
c)transient,
d)protected
Ans = c,d.
Can someone explain ?
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
transient fields wont serialize cause that is what the transient key word do (wont seriliaze the fields).
about the protected.. no clue....
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you get this question Vaibhav? I've never seen anything that says the protected (or public/private, for that matter) modifier affects serialization.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Java Tutorial : Providing Object Serialization for Your Classes


This method automatically writes out everything required to reconstruct an instance of the class, including the following:
- Class of the object
- Class signature
- Values of all non-transient and non-static members, including members that refer to other objects


So the correct answers should be b) and c).
Private and protected (instance) fields are serialized since they pertain to the object itself.
 
Vaibhav Shridish
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey paul
i got that question from this link
http://sanjayahuja.tripod.com/tech/scjp/scjp.html
i could get only 5/20 in the questions from 181
to 200 .....
valentin... Thanks for that link ...
can you let me know how much do you think one
should be scoring in the 200 questions in the
link above?
 
Paul Villangca
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done the first hundred, and guess what - they're all Marcus Green exam questions! So I guess you should be okay with a score of around 80%.
Update: heh, questions seem come from an outdated version of the exam. Some of the questions are still poorly worded, like question #102 (Green's Exam 2-42.)
[ June 19, 2002: Message edited by: Paul Villangca ]
 
Vaibhav Shridish
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good work paul .. i got only 70% in the 1st 100
and guess whatttttt the remaining 100 drove me
crazy and made me forget the basics for a moment
i had spent 2 days analysing the mistakes i have
committed in the remaining 100 and am not yet done
and particularly those questions on strings I
tell you .... 2&^*(^(*&^$&*&6 DROVE ME LITRALLY
mad ... i did an exhausting testing on the way
string class works and found out its really
really wierd. ..
i shall post those questions on strings later
today ....
when are you taking your certification exam ?
 
Paul Villangca
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About the questions on Strings, there's a basic rule I follow:
When a String method will return a String that has the same contents as the original String, it returns the original String object instead. Got that?
For example:
"Hello!".trim() == "Hello!"
returns true.

As for the other difficult ones, well... my only advice is to compile and run them to see what happens.
 
Vaibhav Shridish
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah thanz a lot paul ...
Actually i DISCOVERED that yesterday night ....
and that was the weird behaviour i was talking
abt and never understood properly untill i
experimented again and again.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic