File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes If condition Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "If condition" Watch "If condition" New topic
Author

If condition

asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
please let me know where i am going wrong
In my opinion the x value should be 2, but the answer is 4.
aslika bahini
Ranch Hand

Joined: Mar 03, 2007
Posts: 111
Hi asha,



else if(b=false){ // yes b is false here
x=2;

orginally posted by asha

here.. you are assigning b=false.

if, b == false then, it prints x = 2

regards
samura

Praveen Seluka
Ranch Hand

Joined: Jul 17, 2007
Posts: 95
Hi

The second condition
else if (b=false) is an assignment operation.It assigns b to false and then the if loop becomes false so it wont be x=2.

Thanks
Praveen SP
asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
ok i got it thanks a lot
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: If condition
 
Similar Threads
q from sun's epractice exam
IS if (b ) same as: if (b == true) ???
Boolean Question
fall - through for if-else loop ???
Sun Sample exam: mistake??