aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes transient and protected fields cannot be serialized ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "transient and protected fields cannot be serialized ?" Watch "transient and protected fields cannot be serialized ?" New topic
Author

transient and protected fields cannot be serialized ?

Vaibhav Shridish
Greenhorn

Joined: Jun 06, 2002
Posts: 28
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 ?


Vaibhav Shridish
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
transient fields wont serialize cause that is what the transient key word do (wont seriliaze the fields).
about the protected.. no clue....
Paul Villangca
Ranch Hand

Joined: Jun 04, 2002
Posts: 133
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.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Vaibhav Shridish
Greenhorn

Joined: Jun 06, 2002
Posts: 28
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

Joined: Jun 04, 2002
Posts: 133
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

Joined: Jun 06, 2002
Posts: 28
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

Joined: Jun 04, 2002
Posts: 133
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

Joined: Jun 06, 2002
Posts: 28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transient and protected fields cannot be serialized ?