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

Class declaration??

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i ran up into a question at a mock exam,
Q) Given an Answer class which behaves like a File and has a Vector, a boolean and a color. What is the correct declaration??

I wrote:
public class Answer extends File{
Vector v;
Color c;
boolean b;
}
I was amazed to see the following answer:
public class Answer extends File implements Serializable

Pls clarify

Thanks
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sagar
An odd one. First, I don't think serialization is in the Programmer's certification objectives - I've just done a quick search on the objectives at Marcus Green's site and didn't get a hit.
Second, the question looks like a "is a" versus a "has a" object theory question and I would have answered as you did, except that, judging by the supplied answer, they only wanted the class declaration. If that was made clear in the question then it might have been a cryptic clue to the answer they wanted.
Thirdly, the File class implements Serializable, so by extending File your Answer class also implements Serializable. This means your answer also contains the correct answer.
But, all that aside, and working backwards from the answer they've given, I guess their rationale is that "behaving like a file" means achieving some sort of persistence and the Serializable interface enables a type of persistence, I suppose.
Hopefully the real test won't have such a loose question, and hopefully we don't need to cover Serializable.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic