Operators in JAVA: Learn in an easy way
Operators in Java: solved Java program for ICSE Class 9 Computer Applications with complete BlueJ code, explanation and sample output.
In this program, arithmetic operators are used.
Variables and Data type
class operators
{
public static void main()
{
int a=10;
int b=2;
int sum=a+b;
int subtract=a-b;
int product=a*b;
int divide=a/b;
int modulus=a%b;
System.out.println("The sum is "+sum);
System.out.println("The minus of a & b is "+subtract);
System.out.println("The product is "+product);
System.out.println("The quotient is "+divide);
System.out.println("The modulus is "+modulus);
}
}OUTPUT:
The sum is 12
The minus of a & b is 8
The product is 20
The quotient is 5
The modulus is 0
Watch Java videos
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.