File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question regarding serialization - examlab mistake? 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 "question regarding serialization - examlab mistake?" Watch "question regarding serialization - examlab mistake?" New topic
Author

question regarding serialization - examlab mistake?

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I think that I have marked the correct answer - static variables are not serializable.


[Thumbnail for ExamLabSerialization.JPG]


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Can anybody analyze that? Devaka?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3214
    
  49

Yep another, thanks again.
Anyway the exception is thrown because Tree is not serializable. Not because of the static usage.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Sorry my mistake. I forgot the important point that declaring is a way of telling the JVM that the objects of this class is serializable.But then I had selected Compilation fails as basically we don't select static instances for for writng to the file that is. I don't know even i got it wrong


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

OK, so the question is correct. My mistake, sorry.
But on the other hand: why we can use "static transient" combination? Static variables are not serializable.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3214
    
  49

This question is initially designed for the serialization of Forest instance, and it has been changed with the new release. That's the problem with this question
For this question, if the Tree is-a Serializable, you can serialize it even the variable 'tree' is static.
Static variables are implicitly transient - that's true, but it will not apply here, because we are serializing the object of the tree variable directly.

Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

I guess the answer is right. This example below gives a runtime exception which is same as the question




well instance serializes if the class was serializable.... Then when it is deserialized what will be the value?
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Yeah, the question is good. Only a small mistake in explanation of this question.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3214
    
  49

Nitish Bangera wrote:I guess the answer is right.


Yes, the answer is 'right'.
But the problem is with the given explanation, I have to change it.
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

What would be the new explanation.....please give it here.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3214
    
  49

Nitish Bangera wrote:What would be the new explanation.....please give it here.


Simply, Tree is-not Serializable
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Ok i thought something else will be there So asked.....well i tried out examlab final and it was tough real tough....i just need to take care on my silly mistakes for questions like false and not true. Devaka great prep mock.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3214
    
  49

Nitish Bangera wrote:i just need to take care on my silly mistakes for questions like false and not true.


Hope it would increase your eyesight
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

That's the main problem as i have glasses too. Well anyways i will take care as your examlab has helped me alot.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I have completed the Final Exam - I think that's the hardest one from between other Devaka's exams.
I have scored 72%.
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

i scored 62% it was really hard......got to watch out for mistakes.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

How long have you been preparing for SCJP?
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Well i knew java but i started preparation exclusively for SCJP last month...... What about you?
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I have been preparing for about one month and a half. I've known Java for about a year (no commercial projects) - I am a student.
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Yeah well i am a student too..... I used to work using c and C++ and for web dev php and mysql. Got back to java after a year now. Well but java is really better once you know the things. Specially i like java for their thread usage in multicore technologies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question regarding serialization - examlab mistake?