+ 2
Int x=2,y=2; if(++x>2 && y-->2)
Why this condition is false
3 Answers
+ 2
Because
2 > 2 is false so (true && false) will be false
+ 2
Also, logical AND operator will evaluate the RHS operand when the LHS operand evaluates to true. So here, both `++x > 2` and `y-- > 2` are evaluated.
This will not be the case when the LHS operand evaluates to false, as per the short circuit evaluation definition.
0
(++x>2 && y-->2)
Evaluates to
(3>2 && 2>2)
Then
(True && False)
And finally reduces to
(False)