0
0
Javaprogramming~5 mins

Arithmetic operators in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are arithmetic operators in Java?
Arithmetic operators are symbols used to perform basic math operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Click to reveal answer
beginner
What does the modulus operator (%) do?
The modulus operator (%) gives the remainder after dividing one number by another. For example, 7 % 3 equals 1 because 7 divided by 3 leaves a remainder of 1.
Click to reveal answer
beginner
What is the result of integer division in Java?
When dividing two integers, Java returns the quotient without the decimal part. For example, 7 / 3 equals 2, not 2.333.
Click to reveal answer
beginner
How do you perform multiplication in Java?
Use the asterisk (*) symbol between two numbers. For example, 4 * 5 equals 20.
Click to reveal answer
intermediate
What happens if you divide by zero in Java?
Dividing an integer by zero causes a runtime error called ArithmeticException. Dividing a floating-point number by zero results in Infinity or NaN.
Click to reveal answer
Which operator is used for addition in Java?
A*
B+
C-
D%
What is the output of 10 % 4 in Java?
A6
B0
C2
D4
What is the result of 9 / 2 when both are integers?
A4
B4.5
C5
D2
Which operator multiplies two numbers?
A-
B+
C/
D*
What happens if you divide an integer by zero in Java?
AThrows ArithmeticException
BReturns Infinity
CReturns zero
DReturns NaN
Explain the difference between division and modulus operators in Java.
Think about what happens when you divide numbers and what is left over.
You got /3 concepts.
    Describe what happens when you use arithmetic operators on integers versus floating-point numbers in Java.
    Consider how Java treats whole numbers and decimals differently.
    You got /4 concepts.