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

Externalizable Class , Can any one help ?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one please see the below code snippet and tell me what could the correct result

I was preparing for SCJP exam and I got stuck with such a question

[i]import java.io.*;
[/i]
List of choices are

1. The program will compile and run normally to produce the desired output.
2. The program will not compile as it is not possible for the Circle class to implement
both the Serializable and Externalizable interfaces.
3. The program will complain at run-time telling that there is no default constructor for
the class 'Square'.
4. The program will complain at run-time telling that there is no default constructor for
the class 'Circle'.
 
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Hassan Ebied",

Please Quote Your Sources.

Thanks,
Henry
 
Hassan Ebied
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Hinry for your comment
and sorry for posting question without qouting the sources which violate the rules

I have got the above questions from Mock exams bought from javabeat.com , objective 3

http://www.javabeat.net/javabeat/scjp5/mocks/scjp-5-0-objective3.php

 
Ranch Hand
Posts: 826
Eclipse IDE Oracle Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think not quoting your sources does not violate the rule as far as i think..but it is provided for the poster and so that the reader could read it in a very clear manner and can also refer to the code through line numbers. So just quoting the source makes everything easy and makes every one happy
 
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 an Externalizable object is reconstructed, an instance is created using the public no-arg constructor, then the readExternal method is called.
Since the class circle doesn't contain a non-arg constructor and compiler doesn't provide non-arg constructor , it should complain at run time telling that there is no default constructor for class circle. So answer should be 4.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep in mind sports fans that Externalizable is NOT on the SCJP exam.

hth,

Bert
 
Hassan Ebied
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Mumtaz ,,

Externizable is an interface not a class , so it has no constructors

When I compiled this code and run it , it gave me the desired output

Bert , Are you sure that this class will not be included in the exam. I dont know , If I will face such question in the exam I will tell them that Bert told me that it is not included in the exam and no body will care about me.
 
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hassan, if you have read K&B -6, you will realize that Externalizable is not for the exam.
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hassan,

Well, no one is perfect, as anyone who has been at the ranch for a while can tell you, I've made my share of mistakes... okay, lots more than my share . But I will say that I'm very careful when I make a statement like that.

hth,

Bert
 
Hassan Ebied
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bert ,

I am sorry I missed what i want to say


Many thany thanks for you words , I really appreiate all replies and I did not meant to heart any one . I just wanted to say it in funny way,,,,


Again sorry Bert and Thanks ofcourse
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No worries Hassan,

good luck with your studies,

Bert
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic