0% found this document useful (0 votes)
7 views5 pages

Java Programming Operators Explained

The document provides Java programming code examples demonstrating various types of operators including arithmetic, relational, logical, bitwise, and assignment operators. Each section includes a code snippet followed by its expected output. The examples illustrate the functionality of each operator in a clear manner.

Uploaded by

pravindsawate
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Java Programming Operators Explained

The document provides Java programming code examples demonstrating various types of operators including arithmetic, relational, logical, bitwise, and assignment operators. Each section includes a code snippet followed by its expected output. The examples illustrate the functionality of each operator in a clear manner.

Uploaded by

pravindsawate
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name:-Sangharsh parvind Sawate

Class:-co4k(B)

Roll no:-64

Sub:-java programming(314117)

*Arithmetic operators
Code:-
public class arithmetic
{
public static void main(String args[])
{
int a=20;
int b=10;
int c=a+b;
[Link]("a+b="+c);
c=a-b;
[Link]("Subsration a-b is="+c);
c=a*b;
[Link]("Multiplication a*b="+c);
c=a/b;
[Link]("Division a/b is="+c);
c=a%b;
[Link]("Modules a % b="+c);
}
}

Output:-
*Relational operators
Code:-
public class Relation
{
public static void main(String[] args)
{
int a = 10, b = 15, c = 15;
[Link]("Relational Operators and returned values");
[Link](" a > b = " + (a > b));
[Link](" a < b = " + (a < b));
[Link](" b >= a ="+ (b >= a));
[Link](" b <= a ="+ (b <= a));
[Link](" b == c =" + (b == c));
[Link](" b != c =" + (b != c));
}
}
Output:-
*Logical operator
Code:-
public class logical
{
public static void main(String args[])
{
boolean a = true;
boolean b = false;
[Link]("a&&b="+(a&&b));
[Link]("a||b="+(a||b));
[Link]("a!(a&&b)="+(a&&b));
}
}

Output:-

*Bitwise operator
Code:-
public class s
{
public static void main(String[] args)
{
int a = 60;
int b = 13;
int c = 0;
c = a & b;
[Link]("a & b = " + c);
c = a | b;
[Link]("a | b = " + c);
c = a ^ b;
[Link]("a ^ b = " + c);
c = ~a;
[Link]("~a = " + c);
c = a << 2;
[Link]("a << 2 = " + c);
c = a >> 2;
[Link]("a >> 2 = " + c);
c = a >>> 2;
[Link]("a>>> 2="+c);
}
}
Output:-
*Assignment operator
Code:-
public class tet
{
public static void main(String[] args)
{
int a = 10;
int b = 20;
int c = 0;
c=a+b;
[Link]("c = a + b = " + c);
c -= a;
[Link]("c -= a = " + c);
c *= a;
[Link]("c *= a = " + c);
a = 10;
c = 15;
c /= a;
[Link]("c /= a ="+c);
}
}
Output:-

You might also like