Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Java | Operators | Question 2

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Predict the output of following Java program. Assume that int is stored using 32 bits.




class Test {
    public static void main(String args[])  {
       int x = -1;  
       System.out.println(x>>>29);  
       System.out.println(x>>>30);  
       System.out.println(x>>>31);  
   }   
}


(A)

7
3
1

(B)

15
7
3

(C)

0
0
0

(D)

1
1
1


Answer: (A)

Explanation: Please see https://www.geeksforgeeks.org/bitwise-shift-operators-in-java/

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads