मराठी

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer. public class test { public static void main(String args[]) { int x, y; x = 5 >> 2; y

Advertisements

प्रश्न

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.

public class test {
public static void main(String args[]) {
int x, y;
x = 5 >> 2;
y = x>>> 2;
System.out.println(y);
}
}
लघु उत्तर
Advertisements

उत्तर

Initially, x = 5

1. x = 5 >> 2;

The signed right shift operator (>>) shifts the bits two positions to the right.

x = 5 >> 2 = 1

2. y = x >>> 2;

The unsigned right shift operator (>>>) shifts the bits two positions to the right and fills the leftmost bits with zeros.

y = 1 >>> 2 = 0

Output:

0

 
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३४]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 57. | पृष्ठ १३४
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×