Arithmetic Operators program in java
class ArithmeticOperators {
public static void main(String args[]) {
int num1=8,num2=2;
System.out.println("+ Operator , Addition of num1 and num2 is "+(num1+num2));
System.out.println("- Operator , Subtraction of num1 and num2 is "+(num1-num2));
System.out.println("* Operator , Multiplication of num1 and num2 is "+(num1*num2));
System.out.println("/ Operator , Division of num1 and num2 is "+ (num1/num2));
System.out.println("% Operator , Modulus of num1 and num2 is "+(num1%num2));
}
}
Bitwise Operators program in java
class BitwiseOperator {
public static void main(String args[]) {
int val1=3,val2=6;
int val_OR = val1 | val2;
int val_AND = val1 & val2;
int not = ~val1;
int val_ExOR = val1 ^ val2;
int rightshift = val1 >> 2;
int leftshift = val1 << 2;
System.out.println("| Operator " +val_OR);
System.out.println("& Operator " +val_AND);
System.out.println("~ Operator " + not);
System.out.println("^ Operator " +val_ExOR);
System.out.println(">> Operator "+rightshift);
System.out.println(">> Operator "+leftshift);
}
}