Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Textbook based notes

Rating
-
Sold
-
Pages
9
Uploaded on
25-02-2026
Written in
2025/2026

This is JAVA notes

Institution
Course

Content preview

Object Oriented Programming with JAVA BCS306A

MODULE-I
Chapter 3 Operators
➢ Java provides a rich operator environment.
➢ Most of its operators can be divided into the following four groups: arithmetic, bitwise,
relational, and logical.

3.1 Arithmetic Operators
➢ Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra.
➢ The following table lists the arithmetic operators:




The Basic Arithmetic Operators
➢ The basic arithmetic operations—addition, subtraction, multiplication, and division— all
behave as you would expect for all numeric types.
➢ The minus operator also has a unary form that negates its single operand.
➢ Remember that when the division operator is applied to an integer type, there will be no
fractional component attached to the result. The following simple example program demonstrates
the arithmetic operators.
class BasicMath {
public static void main(String args[]) {
System.out.println("Integer Arithmetic");
int a = 1 + 1;
int b = a * 3; Integer Arithmetic
a=2
int c = b / 4;
b=6
int d = c - a; c=1
int e = -d; d = -1
System.out.println("a = " + a); e=1
System.out.println("b = " + b); Floating Point Arithmetic
System.out.println("c = " + c); da = 2.0
System.out.println("d = " + d); db = 6.0
dc = 1.5
System.out.println("e = " + e);
dd = -0.5
de = 0.5

1

, Object Oriented Programming with JAVA BCS306A

// arithmetic using doubles
System.out.println("\nFloating Point Arithmetic");
double da = 1 + 1;
double db = da * 3;
double dc = db / 4;
double dd = dc - a;
double de = -dd;
System.out.println("da = " + da);
System.out.println("db = " + db);
System.out.println("dc = " + dc);
System.out.println("dd = " + dd);
System.out.println("de = " + de);
}
}

The Modulus Operator(%)
➢ The Modulus Operator returns the remainder of a division operation.
➢ It can be applied to floating-point types as well as integer types.
class Modulus {
public static void main(String args[]) {
int x = 42; Output:
x mod 10 = 2
double y = 42.25;
y mod 10 = 2.25
System.out.println("x mod 10 = " + x % 10);
System.out.println("y mod 10 = " + y % 10);
}
}

Arithmetic Compound Assignment Operators
➢ Java provides special operators that can be used for all of the arithmetic, binary operators. Thus,
any statement of the form
var = var op expression;
➢ can be rewritten as
var op= expression;
➢ The compound assignment operators provide two benefits. First, they save you a bit of typing,
because they are “shorthand” for their equivalent long forms. Second, they are implemented
more efficiently by the Java run-time system than are their equivalent long forms.

class OpEquals {
public static void main(String args[]) {
int a = 1;
int b = 2;
int c = 3; Output:
a=6
a += 5;
b=8
b *= 4; c=3
c += a * b;
c %= 6;


2

Written for

Institution
Course

Document information

Uploaded on
February 25, 2026
Number of pages
9
Written in
2025/2026
Type
OTHER
Person
Unknown

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
yashaswinir

Get to know the seller

Seller avatar
yashaswinir
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 months
Number of followers
0
Documents
4
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions