Programming Tutorials

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

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

<< is the left shift operator in Java. It shifts the bits of the first operand (5 in this case) to the left by the number of positions specified in the second operand (2 in this case). Shifting left by n positions is equivalent to multiplying by 2^n.

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

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Interview )

What types of comments are available in the JSP?

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

Question: What is a Hidden Comment in JSP?

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

What are the call back methods in Session bean?

Question: How is the MVC design pattern used in Struts framework?

Interview Question: Write code of any Action Class?

Interview Question: What is deployment descriptor?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Interview Question: What is the difference between find and select methods in EJB?

What do you understand by Synchronization?

Interview Question: What are the call back methods in Entity bean?

Interview Question: Is Decorator an EJB design pattern?

Explain the different forms of Polymorphism.

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

Latest Articles (in Interview)