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
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

Explain garbage collection?

What is Collection API?

What is the difference between jsp:include page and @ include file?

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

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

Question: Difference between forward and sendRedirect in JSP?

Interview Question: Write code of any Action Class?

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

Interview Question: What is Local client view in EJB?

What do you understand by Synchronization?

What is the difference between JTS and JTA?

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

Question: How would you go about analyzing performance of an application?

What is similarities/difference between an Abstract class and Interface?

Interview Question: Can i map more than one table in a CMP?

Latest Articles (in Interview)