Explain the Various Types of Bitwise Operators in Java.
Advertisements
प्रश्न
Explain the Various Types of Bitwise Operators in Java.
स्पष्ट करा
Advertisements
उत्तर
- Bitwise AND Operator (
&): This operator compares the corresponding bits of two operands and returns1only when both bits are1. Otherwise, it returns0. - Bitwise OR Operator (
|): This operator compares the corresponding bits of two operands and returns1if at least one of the bits is1. Otherwise, it returns0. - Bitwise XOR Operator (
^): This operator compares the corresponding bits of two operands and returns1when the bits are different. If both bits are the same, it returns0. - Bitwise Complement Operator (
~): This is a unary operator that reverses all the bits of an integer value. It changes0to1and1to0. - Left Shift Operator (
<<): This operator shifts the bits of a number to the left by the specified number of positions. Zeros are inserted into the vacant positions on the right. - Signed Right Shift Operator (
>>): This operator shifts the bits of a number to the right by the specified number of positions while preserving its sign. - Unsigned Right Shift Operator (
>>>): This operator shifts the bits of a number to the right by the specified number of positions and fills the vacant positions on the left with zeros.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]
