wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question from mock test, couldnt understand Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "question from mock test, couldnt understand" Watch "question from mock test, couldnt understand" New topic

question from mock test, couldnt understand

Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
hai friends,
The question given below was from the Marcus Green mock test1. iam unable to get the question, plz explain it.
Which of the following most closely describes a bitset collection?
1) A class that contains groups of unique sequences of bits
2) A method for flipping individual bits in instance of a primitive type
3) An array of boolean primitives that indicate zeros or ones
4) A collection for storing bits as on-off information, like a vector of bit

thanking you
Tushar Gorde

Joined: Jan 30, 2004
Posts: 3
Answer is 1.
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
Sets have only unique values, no duplicates...

How simple does it have to be???
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
Ah, but BitSet is a class left over from Java 1.0 and does not implement the Set interface. It is really more like a BitVector - just one more example of naming confusion created as Java grew. Therefore, answer 3 is correct.
Simply looking at the JavaDocs for java.util.BitSet would have revealed this. You really should make a habit of it.
Don Wood
Ranch Hand

Joined: Dec 05, 2003
Posts: 65
This question threw me too. It smells like a set but isn't one. How annoying.
But there is another odd thing in answer three:

3) An array of boolean primitives that indicate zeros or ones

As Bill suggested, I looked BitSet up in JavaDoc and it says

Each component of the bit set has a boolean value.

Now we all know that you cannot assign either a zero or a one to a boolean. So anwser three still seems a bit off. In defense of the wording, the class has methods that set, flip and clear bits which sounds more like zeroes and ones than booleans.
Another confusing detail:
JavaDoc says "This class implements a vector of bits...". This is not to be confused with java.util.Vector which takes objects, not primitives.
So BitSet is a vector of bits that is neither a Set nor a Vector. As a language evolves you often see odd quirks like this. Even Java has its share.
Philippe Maquet

Joined: Jun 02, 2003
Posts: 1872
After having read the BitSet doc, I'd have chosen 4), without much hesitation.
Bert Bates

Joined: Oct 14, 2002
Posts: 8801
I haven't gotten to be "the focus police" for a while
The exam creators didn't consider BitSet to be part of the "collections framework" as it doesn't implement Collection, Set, List, or Map. So you can relax, and not worry about BitSets for the exam. If, on the other hand, you're goal is to memorize the entire API, then BitSet is a card carrying member

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
I agree. Here's the link: http://aspose.com/file-tools
subject: question from mock test, couldnt understand
Similar Threads
Java Ranch Mock Exam Question
bitset collection
sensible way of sending error page to the client
Mock exam questions
regarding a RequestDispatcher object