Answer to Question #3565 in Java | JSP | JSF for Y mukundareddy

Question #3565
(3) Write a program to perform all bitwise operators on the following variables a=50, b=20?
1
Expert's answer
2017-01-20T09:13:45-0500
public class Bitwise {

static int a = 50;
static int b = 20;

public static void main(String[ ] args) {
int c = a^b;
System.out.println("a ^ b =" +c);
c = a&b;
System.out.println("a & b =" +c);
c = a|b;
System.out.println("a | b =" +c);
c = a^b;
System.out.println("a ^ b =" +c);
a&=b;
System.out.println("a &= b =" +a);
a = 50;
a^=b;
System.out.println("a ^= b =" +a);
a = 50;
a|=b;
System.out.println("a |= b =" +a);
a = 50;
c = a<<b;
System.out.println("a << b =" +c);
c = a>>b;
System.out.println("a >> b =" +c);
c = a>>>b;
System.out.println("a >>> b =" +c);
a<<=b;
System.out.println("a <<= b =" +a);
a = 50;
a>>=b;
System.out.println("a >>= b =" +a);
a = 50;
a>>>=b;
System.out.println("a >>>= b =" +a);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS