File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Class declaration?? 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 "Class declaration??" Watch "Class declaration??" New topic

Class declaration??

Sagar Sharma
Ranch Hand

Joined: Aug 31, 2000
Posts: 92
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

greg clarke

Joined: Oct 06, 2000
Posts: 25
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.
I agree. Here's the link:
subject: Class declaration??
jQuery in Action, 3rd edition