0% found this document useful (0 votes)
13 views2 pages

Bitwise (1) 1

Uploaded by

syediliyas8282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Bitwise (1) 1

Uploaded by

syediliyas8282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: Syed iliyas

Practical No:1(A)

Aim: program on bitwise opeator

public class BitwiseOperatorDemo {


public static void main(String[] args) {
int a = 5; // Binary: 0101
int b = 3; // Binary: 0011

// Bitwise AND
System.out.println("a & b = " + (a & b)); // Output: 1 (0001)

// Bitwise OR
System.out.println("a | b = " + (a | b)); // Output: 7 (0111)

// Bitwise XOR
System.out.println("a ^ b = " + (a ^ b)); // Output: 6 (0110)

// Bitwise NOT
System.out.println("~a = " + (~a)); // Output: -6 (inverts bits)

// Left Shift
System.out.println("a << 1 = " + (a << 1)); // Output: 10 (1010)

// Right Shift
System.out.println("a >> 1 = " + (a >> 1)); // Output: 2 (0010)
}
}

You might also like