File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes shortcut circuit Q Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "shortcut circuit Q" Watch "shortcut circuit Q" New topic

shortcut circuit Q

Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Hi guys

I had a quiestain on one of the mock exams I'm doing on which are "Shorcut Circuit" operators.

1. &
2. |
3. ||

I thought I knew what the shortcut circuit oprators means:
If the left side is true, we don't avaluate the right side.

I gave the answer | and || BUT the test gave the answer & and ||.
How come & is a shortcut circuit operator?
When we have: if(true & false) we still have to avaluate the right side and the result will be false.

Can someone solve me this dilema? (:

Thnx in advance
Dror (:
Balazs Borbely
Ranch Hand

Joined: Oct 11, 2004
Posts: 33
The Short-circuit opertors are: && and ||

Conditional AND Operator &&

-both operands must be boolean
-result is a boolean
-returns true if both operands are true, otherwise false
-evaluates the right-hand operand only if the left-hand operand is true


Conditional OR Operator ||
-both operands must be boolean
-result is a boolean
-returns true if one of the operands is true
-evaluates the right-hand operand only if the left-hand operands is false


'Make everything as simple as possible, but not simpler.' --Albert Einstein
Prateek Duble

Joined: May 17, 2005
Posts: 22
I am a beginner but still I am very clear about Short Circuit and Non-Short Circuit operators.
Short Circuit Operators are && and || ONLY.
Non Short Circuit Operators are & and | ONLY.

So, According to me , Answer should only be && .

(Note: I am referring HEAD FIRST JAVA new edition and it also says so).

Plz let me know if I m wrong or missed something.


Prateek J. Duble
I agree. Here's the link:
subject: shortcut circuit Q
jQuery in Action, 3rd edition