Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain the difference between the Boolean & operator and
the && operator?

Answer Posted / ranganathkini

This can be explained with an example

1. The bitwise AND operator ( & )

(boolean expression1) & (boolean expression2)

to evaluate the above expression, Java first evaluates both
boolean expression1 and boolean expression2

hence only if both boolean expression1 and boolean
expression2 evaluate to true, the whole expression evaluates
to true.

2. The conditional AND operator ( && )

( boolean expression1 ) && ( boolean expression2 )

Here Java first evaluates boolean expression1, only if it
evaluates to true, boolean expression2 is evaluated. Hence
boolean expression2 is not evaluated if boolean expression1
evaluates to false.

The conditional AND operator, sometimes called the
short-circuit operator is more efficient that the bitwise
AND operator. As it saves the processing of expression2 by
first evaluating expression1 and ascertaining that the final
result will be false.

Is This Answer Correct ?    25 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is integer a class?

1014


What's the base class of all exception classes?

1013


What causes memory leak in java?

884


Explain the significance of class loaders in bootstrap?

891


Can we create our own wrapper class in java?

908


Can a main method be overloaded?

965


Explain about the dynamic behavior of core java?

1068


How many types of the indexof method are there for strings?

920


How big is a 64 bit float?

951


How do you trim a space in java?

923


Which command from the jdk compiles a java program?

916


Do I need java for windows 10?

976


What is super in java?

934


do I need to use synchronized on setvalue(int)? : Java thread

957


What is number data type in java?

943