Programming Tutorials

The output of System.out.println(5>>2) in Java

By: Nirmal in Interview Tutorials on 2023-05-11  

>> is the right shift operator in Java. It shifts the bits of the first operand (5 in this case) to the right by the number of positions specified in the second operand (2 in this case). Shifting right by n positions is equivalent to dividing by 2^n and taking the floor.

In this case, 5 is represented in binary as 00000101. When we shift it right by two positions, we get 00000001, which is the binary representation of 1. Therefore, the output of the System.out.println(5>>2) statement is 1.

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Interview )

What is Collection API?

What is the difference between Session Bean and Entity Bean?

What types of comments are available in the JSP?

Interview Question: Why it is called Struts?

What are all the different scope values for the tag?

Interview Question: What is EJB client JAR file?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

What is the difference between JTS and JTA?

What is Deployment Descriptor?

Getting started with Interview

Interview Question: What is the difference between EAR, JAR and WAR file?

Interview Question: Why are some of the class and element names counter-intuitive?

Interview Question: Is Decorator an EJB design pattern?

Question: What is a Hidden Comment in JSP?

Latest Articles (in Interview)