• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question regarding serialization - examlab mistake?

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that I have marked the correct answer - static variables are not serializable.
ExamLabSerialization.JPG
[Thumbnail for ExamLabSerialization.JPG]
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody analyze that? Devaka?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4600
306
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep another, thanks again.
Anyway the exception is thrown because Tree is not serializable. Not because of the static usage.
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4600
306
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, the question is good. Only a small mistake in explanation of this question.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4600
306
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would be the new explanation.....please give it here.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4600
306
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitish Bangera wrote:What would be the new explanation.....please give it here.


Simply, Tree is-not Serializable
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4600
306
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i scored 62% it was really hard......got to watch out for mistakes.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How long have you been preparing for SCJP?
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i knew java but i started preparation exclusively for SCJP last month...... What about you?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic