Write a Java-program to print bitwise RIGHT SHIFT operation ?

Write a Java-program to print bitwise RIGHT SHIFT operation ?

Program
public class Main
{
	public static void main(String args[])
	{
        int x=10,z
        z=x>>2; 
        System.out.println("Bitwise Right Shift is: "+(z)); 
	}
}	

Output:

Bitwise Right Shift is: 2

Using CommandLine Arguments
public class Main
{
	public static void main(String args[])
	{
        int x,z;
        x=Integer.parseInt(args[0]);
        z=x>>2;  
        System.out.println("Bitwise Right Shift is: "+(z)); 
	}
}	

Output:

Bitwise Right Shift is: 2

Using Scanner Class
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
        int x,z;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter x value");
        x=s.nextInt();
        z=x>>2; 
        System.out.println("Bitwise Right Shift is: "+(z));     
        
	}
}	

Output:

Enter x value
10
Bitwise Right Shift is: 2





More Questions


20 . Write a Java-program to print bitwise RIGHT SHIFT operation
21 . Write a Java-program to print odd or even number using ternary operator
22 . Write a Java-program to print max number using ternary operator
23 . Write a Java-program to print MAX Number Amoung 3 Numbers
24 . Write a Java-program to print ODD or Even Number using if else condition
25 . Write a Java-program to print max number using if else condtion
26 . Write a Java-program to check the given number is valid or invalid(value must divisible by 2 and 3)
27 . Write a Java-program to check the given number is valid or invalid(value must divisible by 2 and 3 not 4)
28 . Write a Java-program to check the given number is valid or invalid(value must divisible by 2 and 3 not 4 using 2 conditions)
29 . Write a Java-program to check the given number is valid or invalid(value must between 20 and 30)
30 . Write a Java-program to check the given character is vowel or consonant