aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "shortcut circuit Q" Watch "shortcut circuit Q" New topic
Author

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

i.e.


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

i.e.


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

Joined: May 17, 2005
Posts: 22
Hi,
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.

Regards,


Prateek J. Duble
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: shortcut circuit Q