Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
- Interview Questions and Answers for 'Right shift' - 2 question(s) found - Order By Newest | ||||
| ||||
Ans. Both bitwise right shift operator ( >> ) and bitwise zero fill right shift operator ( >>> ) are used to shift the bits towards right. The difference is that >> will protect the sign bit whereas the >>> operator will not protect the sign bit. It always fills 0 in the sign bit. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. public class RightShiftCharacter { public static void main(String args[]) { String str = "Hello"; char[] charArray = str.toCharArray(); for(int count=charArray.length-1;count>0;count--){ charArray[count] = charArray[count-1]; } String newString = new StringBuilder().append(charArray).toString(); System.out.println(newString); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||