System.out.println(4 | 3);
-
6
-
0
-
1
-
7
The bitwise OR operation 4 | 3 works on the binary representations: 4 is 100 and 3 is 011. OR produces 111 (binary) which is 7 in decimal. Each bit position is 1 if either operand has a 1 in that position.
To answer this question, we need to understand the bitwise OR operation.
The bitwise OR operation (|) is a binary operation that takes two operands and performs a bitwise OR on each corresponding bit of the operands.
In this case, we have the numbers 4 and 3. Let's convert them to binary:
4 in binary: 100 3 in binary: 011
Performing the bitwise OR operation on each corresponding bit, we get:
100
OR 011
111
Converting the result back to decimal, we get 7.
So, when we execute the statement System.out.println(4 | 3);, the output will be 7.
Therefore, the correct answer is option D.