1.

What Is Difference Between & And && Operator?

Answer»

& is a bitwise operator while && is a logical operator. ONE difference between & and && is that bitwise operator (&) can be applied to both integer and boolean but logical operator (&&) can only be applied to boolean variabes. When you do a & b then AND operator is applied to each bit of both integer number, while in case of of a && b , SECOND argument MAY or may not be evaluated, that's why it is also known as short circuit operator, at least in Java. I like this question and OFTEN ASKED it to junior or developer and college graduates.

& is a bitwise operator while && is a logical operator. One difference between & and && is that bitwise operator (&) can be applied to both integer and boolean but logical operator (&&) can only be applied to boolean variabes. When you do a & b then AND operator is applied to each bit of both integer number, while in case of of a && b , second argument may or may not be evaluated, that's why it is also known as short circuit operator, at least in Java. I like this question and often asked it to junior or developer and college graduates.



Discussion

No Comment Found