Java MCQ Questions and Answers on Bitwise Operators 2

Study and learn Java MCQ Questions and Answers on Bitwise Operators and their priorities. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Java Theory Notes on Bitwise Operators before reading these objective questions.



1) What is the output of the Java program?
byte b = 0b0000101;
System.out.print(b + ",");
b &= 0b00001111;
System.out.print(b);

 
A) 5, 0
B) 5,5
C) 5,15
D) None
Answer [=]
Answer[=]
2) What is the output of the Java program?
byte b = 0b00000101;
System.out.print(b + ",");
b |= 0b00001111;
System.out.print(b);
A) 5,0
B) 5,5
C) 5,15
D) Compiler error
Answer [=]
Answer[=]
3) What is the output of the Java Program?
byte b = 0b00000101;
System.out.print(b + ",");
b ^= 0b00001111;
System.out.print(b);
A) 5,0
B) 5,5
C) 5,10
D) 5,15
Answer [=]
Answer[=]
4) What is the output of the Java program?
byte b = 0b00000101;
System.out.print(b + ",");
b = (byte)~b;
System.out.print(b);
A) 5, 10
B) 5, -10
C) 5. -6
D) Compiler error
Answer [=]
Answer[=]
5) What is the output of the Java program with Left Shift Operator (<<)?
byte b = 0b00000101;
System.out.print(b + ",");
b = (byte)(b << 1);
System.out.print(b);
A) 5,2
B) 5,5
C) 5,10
D) Compiler error
Answer [=]
Answer[=]
6) What is the output of Java program with Right Shift Operator (>>)?
byte b = 0b00000101;
System.out.print(b + ",");
b = (byte)(b >> 1);
System.out.print(b);
A) 5,-6
B) 5,10
C) 5, 2
D) Compiler error
Answer [=]
Answer[=]
7) What is the output of the Java program with Right Shift (Without Fill Zeroes)?
byte num = (byte)0b1111_1000;
System.out.print(num + ",");
num = (byte)(num >> 1);
System.out.print(num);
A) -8, -16
B) -4, -8
C) -8, -4
D) Compiler error
Answer [=]
Answer[=]


 

8) What is the output of a Java Program with Shift Right Fill Zeroes (>>>) operator?
byte num = (byte)0b1111_1000;
System.out.print(num + ",");
num = (byte)(num >>> 1);
System.out.print(num);
A) -8, 8
B) -8, 4
C) -8, -4
D) Compiler error
Answer [=]
Answer[=]
9) What is the output of Java Program with Shift Right Fill Zeroes operator?
byte num = (byte)0b000_1000;
System.out.print(num + ",");
num = (byte)(num >>> 1);
System.out.print(num);
A) -8, 4
B) 8, 4
C) 8, -4
D) -8, -4
Answer [=]
Answer[=]
10) What is the output of the Java program?
byte num = (byte)0b000_1000;
if(num >> 1 > 6)
{
 System.out.print(num);
}
else
{
 System.out.println(num>>1);
}
A) 8
B) 6
C) 4
D) Compiler error
Answer [=]
Answer[=]
11) What is the output of the Java Program?
byte num = (byte)0b000_1000;
if(num >> 1 > 6 || true)
{
System.out.print(num);
}
else
{
System.out.println(num>>1);
}
A) 8
B) 6
C) 4
D) 2
Answer [=]
Answer[=]
12) What is the output of the Java program?
byte num = (byte)0b000_1000;
if(num >> 1 > 6 || true | 2>3)
{
System.out.print(num+1);
}
else
{
System.out.println(num>>2);
}
A) 8
B) 6
C) 9
D) Compiler error
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.