I'm preparing fot SCJP 1.4 ... Can anyone tell me why questions about bitwise operations and bit shifing are on the certification test???
I can understand why its included in the language ... but it seems a waste of my time mental energy to prepare this stuff ... and I'm thinking may be unwise and perhaps unsafe (read error prone) ... to try bit arithmatic on integers in my apps ... and ... Can anyone honestly tell me that they have used this in a real application?? Why?
Why, is a difficult question to answer. It requires a justification which certainly can be challenged. Why, is a dangerous question.
There is not much to bitwise operations. Why not just learn what they want. You move the bits left or right and add zeros or duplicate the sign aleady there. Thats about it. leftmost bit is sign bit. Throw away bit that gets pushed off. add zeros for unsigned shift. use same sign for signed shift.
Then there is XOR ^ that if one or the other is true then the result is true but if both are true or both false then it is false.
Then there is ~ which is negate. if it is false then make it true and if true make it false.
And there is and/or but I won't even mention those.
JAVA is a full language as they say, not a small toy language for demo purposes.
Just because you do not use a particular language feature does not mean no one does. It does not mean we should throw it out either. Programmers doing commnications may need some of these features as well as those doing numerical methods programs, mathematical based calculations, character manipulations and many more. The term scientific programming comes to mind.
Also understanding the bits n bytes of things makes for a better understanding of what goes on. If you work with unicode you will need some of these operations.
So my answer would be requiring some knowledge of bits makes for better understanding and also many jobs will require it.
You will need to ask the real guys why they put it in. I am just guessing.
I think it is reasonable to ask why it is on the SCJP 1.4 exam, as it is supposed to be an introductory exam. The fact that they dropped it from the 1.5 exam indicates that perhaps it is not appropriate for an introductory exam.