This week's giveaway is in the Android forum. We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line! See this thread for details.

Hi Ritu, Consider it stepwise: 1)boolean b1 = false?false:true?false:true?false:true; Evaluate from right to left in steps: true?false:true = false Then true?false:false = false Then false?false:false so finally , b1=false;

2)boolean b2 = false?false true?false true?false:true)); Here, the brackets are evaluated first starting with the innermost bracket on the right. So you have: (true?false:true) = false Then (true?false:false) = false Then (false?false:false) = false so finally, b2 = false

3) boolean b3 = ((false?false:true)?false:true)?false:true; Again the brackets are evaluated first, this time, the innermost bracket is on the left. So starting from LEFT, (false?false:true) = true Then (true?false:true) = false Then false?false:true = true So finally, b3 = true.

So we have now, m1(false) + m1(false) + m1(true) and m1 returns T if true and F if false in (b?"T":"F")

So m1(false) = F m1(false) = F and m1(true) = T

Hence finally we get FFT.

Hope it is clear now ?? [ September 13, 2005: Message edited by: Barry Gaunt ]

hi, in the b1 can be modified without changing the output for simplification like this

here in b1 condition is false so it evaluates (true?false true?false:true)) inside it condition is true so it returns false hence b1 is false.

boolean b2 = false?false: (true?false: (true?false:true)); here fist condition is false so it evaluates (true?false: (true?false:true)) now inside it condition is true so it again returns false hence b2 is false

boolean b3 = ((false?false:true)?false:true)?false:true; here first (false?false:true) is evaluated which results in true, so i becomes boolean b3 = (true?false:true)?false:true; now (true?false:true) is evaluated which results in false so it becomes becomes boolean b3 = false?false:true; and as now condition is false it returns true hence b3 is true.

thus System.out.println(m1(b1) + m1(b2) + m1(b3)); prints FFT

did it make you clear? Sandy [ September 13, 2005: Message edited by: Barry Gaunt ]

Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?

Note:To exterminate "smilies" please use the "disable smilies in this post" checkbox (scroll right the way down to see it) just before you submit your post.