I know that in general we write a condition in an if block but...can we write an expression in an if block as in the following code..
Assume the code is inside main method.
This piece of code is from a scjp questionaire posted on the following link (question 2)
scjp
Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
[Not-so-nice response removed. While we encourage people to put some effort into their posts, there are nice ways to put it, and not-so-nice ways. Be sure to use the former.]
I would regard what the question says as a logic error, but then SCJP questions tend to include weird code which one would never use in real life. Similarly, == false and == true count as poor style.
The correct way to write that expression would have been
if (b2 && b1) . . .
It runs on an internal combustion engine. This ad does not: