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 K&B chap 4, Self test question help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B chap 4, Self test question help" Watch "K&B chap 4, Self test question help" New topic
Author

K&B chap 4, Self test question help

Siri Naray
Ranch Hand

Joined: May 19, 2006
Posts: 105
public class titanic {
public static void main(String[] args)
{
Boolean b1 = true;
boolean b2 = false;
boolean b3 = true;
if((b1&b2) |(b2&b3) &b3)
System.out.println("alpha");
if((b1=false)|(b1&b3)|(b1|b2))
System.out.println("beta");
}

}

No output is produced for this. but since the 2nd "if" results to "true" ((b1&b3)is true also (b1|b2) is true) the output shud be "beta".

Can anyone explain why there is no output for this program???
Thank you in advance
Sirisha


If you worry you cannot work... If you work you need not worry
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Look carefully at the second "if" statement, and ask yourself what this...

(b1 = false)

...is doing.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Siri Naray
Ranch Hand

Joined: May 19, 2006
Posts: 105
wooooooooow how i missed that!1 thank you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: K&B chap 4, Self test question help
 
Similar Threads
clarification if condition
Please explain boxing conversion
Boxing query
logical operator doubt
Explain me this Programm