Skip to content
Related Articles
Open in App
Not now

Related Articles

Java | Operators | Question 2

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
Improve Article
Save 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
Related Articles

Start Your Coding Journey Now!