"fall-through" is unique to the switch statement. x is 4 here because all of the tests in the "if" statements are false, so the last "else" executes. Why do you think this implies "fall-through?"
There is no fall through in the above code. You simply use your basic if else concept and you will get the correct answer.
Mehul Mehta
Greenhorn
Joined: Aug 22, 2006
Posts: 7
posted
0
This question is from the Whizlabs Software and the reference explanation says "fall-thru"; i guess they are wrong there.
I was pretty sure that if-else does not use "fall-thru" since I must have used a billion times ; I decided to put this on the forum for :- 1) Whiz lab Explanation.
2) I was guessing the part "else if (b = false)" would evaluate to TRUE and satisfy the clause and hence X=2; because we are assigning FALSE to 'b' and not checking.