• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bitwise operators

 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran into a problem on the enthuware test which used << which I believe is a bitwise operator. I didn't think those were on the exam anymore. Just wanted to make sure I didn't need to study them. Thanks!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kendall Ponder wrote:I ran into a problem on the enthuware test which used << which I believe is a bitwise operator.

It's actually a bit shift operator and it's the signed left shift operator to be more precise. No need to study them! I even wonder if they are covered on the OCP exam.

&& and || are known as the conditional operators; &, | and ^ are known as the bitwise operators. The conditional operators (which are short-circuit) can only be used with booleans, so you'll see them only in conditions. The bitwise operators are used for bit operations mostly on integral types (byte, short,...) and as their name suggests they do their magic on the actual bits of the value. You could use &, | and ^ on 2 booleans as well. Bitwise operators are less commonly used and their bit-twiddling capabilities are not on the exam. For the exam you only need to know:
  • bitwise operators exist
  • how they work on booleans
  • the difference in behavior with the short-circuit operators
  • There's a huge difference between these 2 statements:

    Nothing better than a little code snippet to demonstratehow they work on booleans:Output:


    Hope it helps!
    Kind regards,
    Roel
     
    Kendall Ponder
    Ranch Hand
    Posts: 205
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks!
     
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 35279
    384
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roel De Nijs wrote:It's actually a bit shift operator and it's the signed left shift operator to be more precise. No need to study them! I even wonder if they are covered on the OCP exam.

    They aren't. Bit shit operators were removed from the SCJP before the split to OCA/OCP. And they happily stayed removed!
     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Jeanne Boyarsky wrote:
    Roel De Nijs wrote:It's actually a bit shift operator and it's the signed left shift operator to be more precise. No need to study them! I even wonder if they are covered on the OCP exam.

    They aren't.

     
    Paul Anilprem
    Enthuware Software Support
    Ranch Hand
    Posts: 3817
    10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Kendall Ponder wrote:I ran into a problem on the enthuware test which used << which I believe is a bitwise operator. I didn't think those were on the exam anymore. Just wanted to make sure I didn't need to study them. Thanks!

    I checked the question bank for it and found only two questions that contained references to it ( 2.1240 and 2.1317). Both the questions are actually about making sure you know valid operators in Java. You don't need to know how they work to answer the question.
    In addition, 2.1240 also tests you on how compound assignments work in general (from casting perspective).

    Please let me know if you saw any other question about it.

    HTH,
    Paul.
     
    Kendall Ponder
    Ranch Hand
    Posts: 205
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Paul Anilprem wrote:
    Kendall Ponder wrote:I ran into a problem on the enthuware test which used << which I believe is a bitwise operator. I didn't think those were on the exam anymore. Just wanted to make sure I didn't need to study them. Thanks!

    I checked the question bank for it and found only two questions that contained references to it ( 2.1240 and 2.1317). Both the questions are actually about making sure you know valid operators in Java. You don't need to know how they work to answer the question.
    In addition, 2.1240 also tests you on how compound assignments work in general (from casting perspective).

    Please let me know if you saw any other question about it.

    HTH,
    Paul.


    2.1240 is the problem I was referring to. You have to pick out the valid constructs which is hard to do if you have ignored the bit shift operators. I take it I should know how they are used for the test?
     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Kendall Ponder wrote:I take it I should know how they are used for the test?

    No! Bit shifting is not even on the OCP exam (as Jeanne mentioned in her previous post).
     
    Kendall Ponder
    Ranch Hand
    Posts: 205
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic