This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
As i have been preparing for SCJA exam, i am in the process of taking up the mock exams available in the net.
One such question i came across is:
Which of the following statement(s) are not true about JavaBeans?
a) JavaBeans implements java.io.serializable interface.
b) JavaBeans provides no argument constructor.
c) JavaBeans provides getter and setter method for accessing its properties.
d) JavaBeans class can contain public instance variable.
e) None of the above
From my understanding of the concepts, i wld answer "d" as accrdng to JavaBeans specs it cannot contain oublic instance variables.
But in the answers given in the same site, "a,d" is what mentioned.
Is it not one of the specifications for Java Beans that it needs to be Serializable?
Mind you I'm no expert (as I am currently studying for the SCJA) but I believe that JavaBeans can implement Serializable but don't by default as I believe they can also implement Externalizable.
Again, I'm not an expert, but that is what I'm thinking. If I am wrong someone is welcome to correct me so I know the proper answer too!
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Joined: Dec 05, 2008
I agree you are right by saying JavaBeans can implement Serializable OR Externalizable.
But still do you think this option(a) can be marked wrong(not true)?
(In this case, guess even the setters and getters need to be coded only by the developer and not given already..)
W. Joe Smith
Joined: Feb 10, 2009
The way I read the answer is that JavaBeans HAS to implement Serializable, which is false. It has to have either Serializable or Externalizable, but if it has Externalizable then it does not have to have Serializable.
I'm not a big fan of this question, but I've had a lot of coursework in my education that teaches me to look at questions from abstract or unusual angles (being an ethics/philosophy minor does that to you!) which sometimes gets me into trouble when I read too deep into questions that are really just face value.
Anyway, the way the question is worded and how I percieve it, A is false since JavaBeans can implement Externalizable and do not have to implement Serializable.
Joined: Dec 05, 2008
This concept of looking at the question from different angles becomes the cause for many such doubtful questions..