Enter the number you wish to multiply as input. After that we use left shift by 2 to multiply given input by four and hence get the output.
Here is the source code of the Java Program to Multiply given Number by 4 using Bitwise Operators. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Multiply_Bitwise
public static void main(String args)
Scanner s = new Scanner(System.in);
System.out.print("Enter the number:");
n = s.nextInt();
int mul = n << 2;
$ javac Multiply_Bitwise.java $ java Multiply_Bitwise Enter the number:5 Answer:20
Sanfoundry Global Education & Learning Series - 1000 Java Programs.