Java Bitwise Operators Interview Questions

Java Bitwise Operators Interview Questions

Here’s Java Bitwise Operators Interview Questions. The level of questions are suitable for beginners as well advanced core Java programmers. This part covers Java Bitwise Operators, and other operators.

Q71. Explain Bitwise OR operator?

A71. The | (Bitwise OR) operator will result in 1 if any of the operand has 1,

Q72. Give an example of Bitwise OR operator (|)?

A72. Here’s an example,

Q73. What does a Bitwise left-shift operator do?

A73. The left-shift operator (<<) shifts all the bits in a value to the left. This is done for a specified number of times.

For example,


Q74. What does a Bitwise right-shift operator do?

A74. The right-shift operator (>>) shifts all the bits in a value to the right. This is done for a specified number of times. For example,


Q75. How both Bitwise left and right shift operators can be easily differentiated?

A75. Left shift operator multiplies a value by specified number of times.

Right shift operator divides a value by specified number of times.

Q76. Give an example of compound bitwise operator assignments?

A76. For example, z >>= 7;

Q77. What are logical binary operators?

A77. The following are logical binary operators,

& = Logical AND
| = Logical OR
^ = Logical XOR
! = Logical Unary NOT

Q78. What is the role of Logical Unary NOT?

A78. Logical Unary NOT operator inverts the boolean state.

For example,


Q79. What are short-circuit logical operators?

A79. The following are the two short-circuit logical operators,
|| – Short-circuit OR
&& – Short-circuit AND

Q80. Is this correct in Java?

A80. Yes, this is chain of assignments that assigns the value of three variables in one statement.

Q81. What is a conditional (ternary) operator?

A81. It is a three-way operator that is for evaluating Boolean expressions,

Q82. Explain conditional operator with an example program?

A82. Here’s an example, that shows both the conditions,


Q83. Operators in the same row are equal in precedence? True or False?

A83. True

Q84. Why Parentheses is used?

A84. Parenthesis i.e. () are used to raise the precedence. It also makes it easy to understand the expression.

Q85. Give an example of using Parenthesis?

A85. Using parenthesis, you can make your expressions easier to read and it do not even decrease the performance of the program,

For example,
1.) 9 + z << x & 29

2.) (((9 + z) << z) & 29)

As you can see the second one is easier to read, thanks to parenthesis.

In this lesson we saw Java Bitwise Interview Questions and Answers.

Java Operators Interview Questions
Java Online Quiz
Studyopedia Editorial Staff
Studyopedia Editorial Staff

We work to create free tutorials for all.

No Comments

Post A Comment