"Actions speak louder than words."
What will be the output of the program?
public static void main(String  args)
boolean b1 = true;
boolean b2 = false;
boolean b3 = true;
if ( b1 & b2 | b2 & b3 | b2 ) /* Line 8 */
if ( b1 & b2 | b2 & b3 | b2 | b1 ) /*Line 10*/
[C]. ok dokey
[D]. No output is produced
[E]. Compilation error
Option Answer: C
& operator has a higher precedence than the | operator so that on line 8 b1 and b2 are evaluated together as are b2 & b3. The final b1 in line 10 is what causes that if test to be true. Hence it prints " dokey".
(Mon, Jan 10, 2011 12:48:18 AM)
Please any one can explain it I have confusion.
Sinu Jos said:
(Tue, Aug 23, 2011 11:24:05 AM)
Can anybody explain me?
(Sat, Dec 17, 2011 07:11:29 PM)
First if is false
and second one is true.
Truth table concept is working here apply that logic you will get ans why first if is false and second one is true.
(Tue, Jun 26, 2012 04:11:56 PM)
I can't understand please explain in the deeply.
Mayur Raiyani said:
(Tue, Jul 3, 2012 01:02:01 PM)
Here is explanation:
(b1 & b2 | b2 & b3 | b2).
(true & false | false & true | false).
(false | false | false).
(b1 & b2 | b2 & b3 | b2 | b1).
(true & false | false & true | false | true).
(false | false | false | true).
(false | true).
Write your comments here: