Java Programming - Operators and Assignments - Discussion
Discussion Forum : Operators and Assignments - Finding the output (Q.No. 9)
9.
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 );
}
}
Answer: Option
Explanation:
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.
Discussion:
34 comments Page 4 of 4.
Divyadharshini said:
8 years ago
Thanks a lot @John.
Ranjitha said:
8 years ago
Thanks for this.
Ekta said:
9 years ago
Thanks @Rashmi.
Piyali said:
9 years ago
Thanks @Satish.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers