Sail E0 Webinar
Question


What will be the output of the program?


class Bitwise
{
public static void main(String [] args)
{
int x = 11 & 9;
int y = x ^ 3;
System.out.println( y | 12 );
}
}
Options:
A .  0
B .  7
C .  8
D .  14
Answer: Option D

The & operator produces a 1 bit when both bits are 1. The result of the & operation is 9. 

The ^ operator produces a 1 bit when exactly one bit is 1; the result of this operation is 10. 

The | operator produces a 1 bit when at least one bit is 1; the result of this operation is 14.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers