English

Explain the Various Types of Bitwise Operators in Java.

Advertisements

Question

Explain the Various Types of Bitwise Operators in Java.

Explain
Advertisements

Solution

  1. Bitwise AND Operator (&): This operator compares the corresponding bits of two operands and returns 1 only when both bits are 1. Otherwise, it returns 0.
  2. Bitwise OR Operator (|): This operator compares the corresponding bits of two operands and returns 1 if at least one of the bits is 1. Otherwise, it returns 0.
  3. Bitwise XOR Operator (^): This operator compares the corresponding bits of two operands and returns 1 when the bits are different. If both bits are the same, it returns 0.
  4. Bitwise Complement Operator (~): This is a unary operator that reverses all the bits of an integer value. It changes 0 to 1 and 1 to 0.
  5. 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.
  6. 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.
  7. 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
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 131]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 18. (ii) | Page 131
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×