
62 • Java Programming
Explanation: For explanation, see the following table, if both the input and output are 1.
b1(12) 00001100
b2(7) 00000111
b1 & b2(4) 00000100
3.7.2 Bitwise OR (|)
Bitwise OR (|) takes two bits as operand and returns the value
1 if at least one operand is 1. If both are 0, only then the result
will be 0, else it is 1 (Table 3.12).
For example, consider the following program:
/*PROG 3.14 DEMO OF BITWISE OR (|)OPERATOR*/
class JPS14
{
public static void main(String args[])
{
byte b1 = 65, b2 = 42;
byte b3 = (byte)(b1 | b2);
System.out.println(“\n\nBehavior of Bitwise OR”);
System.out.println(“\nValue ...