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
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

Question: What is a Hidden Comment in JSP?

What types of comments are available in the JSP?

What do you understand by a container in J2EE?

What are the services provided by a J2EE container?

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

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

Interview Question: What is Deployment descriptor?

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

What do you understand by a J2EE module?

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

Question: Difference between forward and sendRedirect in JSP?

Types of Interviews

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

Interview Question: What is Message Driven Bean?

Interview Question: What is abstract schema?

Latest Articles (in Interview)