1Z0-829 · Question #7
1Z0-829 Question #7: Real Exam Question with Answer & Explanation
The correct answer is D. false 1. Tracing the key values step by step: a = 2, b = ~2 = -3 (bitwise NOT in two's complement: ~n = -(n+1)), c = 2 ^ -3 = -1 (any value XOR its complement equals all-ones = -1) For d: the single & is non-short-circuit - both sides always evaluate. a < b → 2 < -3 → false; a > c++ → 2 >
Question
Options
- Afalse 1
- Bfalse 2
- Ctrue 1
- Dfalse 1
- Etrue 1
- Ffalse 0
Explanation
Tracing the key values step by step:
a = 2,b = ~2 = -3(bitwise NOT in two's complement:~n = -(n+1)),c = 2 ^ -3 = -1(any value XOR its complement equals all-ones = -1)- For
d: the single&is non-short-circuit - both sides always evaluate.a < b→2 < -3→false;a > c++→2 > -1→true, and c post-increments to0. Sod = false & true = false, withc = 0. - For
e: the&&short-circuits only when the left side is false - sincea > b→2 > -3→true, the right side still evaluates:a > c++→2 > 0→true, c post-increments to1. Soe = true, withc = 1. - First
println:false 1. Secondprintln:true 1. Option D is correct.
Why distractors fail: Options showing c = 2 or c = 0 miscount the post-increments - both c++ expressions execute because & never short-circuits and && only skips the right side when the left is false (not true). Options showing d = true misread 2 < -3 as true, forgetting that ~2 is -3, not 3.
Memory tip: Think of &/| as "bitwise bulldozers" - they plow through both sides no matter what. &&/|| are "lazy logical" - they bail early only when the first operand already decides the outcome (false && or true ||).
Topics
Community Discussion
No community discussion yet for this question.