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
[Link]("a & b = " + (a & b)); // Output: 1 (0001)
// Bitwise OR
[Link]("a | b = " + (a | b)); // Output: 7 (0111)
// Bitwise XOR
[Link]("a ^ b = " + (a ^ b)); // Output: 6 (0110)
// Bitwise NOT
[Link]("~a = " + (~a)); // Output: -6 (inverts bits)
// Left Shift
[Link]("a << 1 = " + (a << 1)); // Output: 10 (1010)
// Right Shift
[Link]("a >> 1 = " + (a >> 1)); // Output: 2 (0010)
}
}