hai Soni Prasad, Before answering ur question I will give the order of precedence. |,&,||,&&.This will be the order of precedence for the operators. Answering for the code given by u, the shortcircuit_OR operator won't check for the second value if the first value itself is true.ie,if the first value is false then only it will check for the second value.so in ur code since a is assinged to true,it won't check b and c.while trying to print b and c it will print the default value faulse.If ur code is like this x=((a=true)||(b=true))&&(c=true) then the output will be a=true b=false c=true o.k. regards, udhaya
Joined: Nov 01, 2004
In evaluation of boolean expressions involving conditional AND and OR, the left-hand operand is evaluated before the right one, and the evaluation is short-circuited.
I hope now it is clear.
Joined: Mar 31, 2005
hai mathangi, sorry.I think u r wrong .b'cos shortcircut OR will be given more precedence than shortcircut AND. regards udhaya
In Khalid Mughal book it is given that && has more precedence than || operator. However when iam executing ur code iam getting true,false,false even if iam changing the code as
boolean x = (a = true) || ((b = true) && (c = true)); iam getting the same result. In this case right hand operator should be evaluated first,then b becomes true and then || is evaluated. How come iam getting the same result.can any one please explain.