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?



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

Answer / 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

More Core Java Interview Questions

What is difference between hashset and hashmap in java?

0 Answers  


Write a java program to get a string of words and print the numbers of each word count in descending order

11 Answers   Logica CMG, Subex,


How do I enable java in safari?

0 Answers  


Is vector thread safe in java?

0 Answers  


Write a java program that prints all the values given at command-line.

0 Answers  


What do u mean by variable?

0 Answers  


When do we need to use internal iteration? When do we need to use external iteration?

0 Answers  


What is the difference between Java1.4 and Java1.5

0 Answers   NIIT,


What are the drawbacks of singleton class?

0 Answers  


What is the main purpose of java?

0 Answers  


What are latest features introduced with java 8?

0 Answers  


What are the data types supported by java? What is autoboxing and unboxing?

0 Answers  


Categories