This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B chap 4, Self test question help