Write a Java-program to print bitwise OR operation

Write a Java-program to print bitwise OR operation

Program
public class Main
{
	public static void main(String args[])
	{
        int x=10,y=15,z
        z=x | y;
        System.out.println("Bitwise OR is  "+(z));
	}
}	

Output:

Bitwise OR is 15

Using CommandLine Arguments
public class Main
{
	public static void main(String args[])
	{
        int x,y,z;
        x=Integer.parseInt(args[0]);
        y=Integer.parseInt(args[1]);
        z=x | y;
        System.out.println("Bitwise OR is  "+(z));      
	}
}	

Output:

Bitwise OR is 15

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

Output:

Enter x,y values
10
15
Bitwise OR is 15





More Questions


16 . Write a Java-program to print bitwise OR operation
17 . Write a Java-program to print bitwise CAP operation
18 . Write a Java-program to print bitwise NEGATION operation
19 . Write a Java-program to print bitwise LEFT SHIFT operation
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)