941 views
0 votes
0 votes

What is the difference between the following shift operators : 

A) >>> operator

B) >> operator

C) << operator

1 Answer

Best answer
2 votes
2 votes

(A)Logical Right Shift:-The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.

(B)Arithmetic Right shift :- the signed right shift operator ">>" shifts a bit pattern to the right. 

 

The arithmetic right shift is exactly like the logical right shift, except instead of padding with zero, it pads with the most significant bit. This is because the most significant bit is the sign bit, or the bit that distinguishes positive and negative numbers. By padding with the most significant bit, the arithmetic right shift is sign-preserving.

 

(C)Left shift :-The signed left shift operator "<<" shifts a bit pattern to the left. 

For More Detail : http://stackoverflow.com/questions/141525/what-are-bitwise-shift-bit-shift-operators-and-how-do-they-work

selected by

Related questions

0 votes
0 votes
1 answer
1
LavTheRawkstar asked Jun 29, 2016
958 views
What is the output of the following code segment ?Boolean b= false ;if (b = true)System.out.println("true");elseSystem.out.println("false");(A) true(B) false(C) compiler ...
2 votes
2 votes
1 answer
3
LavTheRawkstar asked Jun 28, 2016
455 views
Why Java does not support multiple inheritance?i want answer in simple words. i have searched for this answer in every textbook.Everytext just says that it doesnot suppor...
0 votes
0 votes
0 answers
4
LavTheRawkstar asked Jun 28, 2016
221 views
Which of the following methods need to be overridden if equals method is overriden? (A) hashCode method(B) toString method(C) compareTo method(D) equal methodcorrect answ...