Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

OCP 815 Study Guide (Sybex) non-short-circuit Operator Question in Bonus Exam 1

 
Saloon Keeper
Posts: 1343
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am one of the people who was disappointed that the bitwise operators were dropped from the OCPJP a long time ago.
They are always dropping stuff I already know and adding new stuff that I don't know yet!

Anyway, this question can't be answered without non-short-circuit logical operator knowledge, as sad as it makes me, you should probably purge it when assembling questions for the next book?

Or am I confused and non-short-circuit & ^ | are still in scope for use with booleans?  It's one of the things that I know anyway, but just to remember when answering questions here.

EDIT/CORRECTION: the non-short-circuit logical operators are apparently still in scope when applied to boolean values.

The important thing to know about them is that their precedence is right above that of the short-circuit || and &&, and that & is higher precedence than ^ which is higher than |...

So these questions are both still fair game.  Annoying, because the only thing I ever forget about them is their precedence, but fine...

Question 45 tb584704.JaSE11PrgISG.be1.39
What are the outputs of the following code snippet? (Choose all that apply.)

 
Jesse Silverman
Saloon Keeper
Posts: 1343
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same question about this question in Bonus Exam 2 for the 815:

tb584704.JaSE11PrgISG.be2.52
What is the result of the following code snippet?


 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you need to know boolean operators.

Fun fact: I've used bitwise operators exactly once in my career. (It was for a bitmask.) The comments I wrote to go with that method were a good amount longer than the method!
 
reply
    Bookmark Topic Watch Topic
  • New Topic