• 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

question from mock test, couldnt understand

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
shyam
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is 1.
 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sets have only unique values, no duplicates...
Davy
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Bill
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After having read the BitSet doc, I'd have chosen 4), without much hesitation.
Regards,
Phil.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic