Java Program to Multiply given Number by 4 using Bitwise Operators

Share on facebook
Share on twitter
Share on linkedin
Share on twitter
Share on tumblr

In this Java program, we will have a glance at how to multiply given numbers by 4 using bitwise operators. A bitwise operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits. 

Multiply given number by 4 using Bitwise Operators in Java

public class MULEXP{ 
static int multiplyWith4(int n) 
{ 
return (n << 2); 
} 

public static void main(String[] args) 
{ 
int n = 15; 
System.out.print(multiplyWith4(n)); 
} 
} 

Output:

60

Leave a Comment

Your email address will not be published. Required fields are marked *