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?
✗ Incorrect
The plus sign (+) is used for addition.
What is the output of 10 % 4 in Java?
✗ Incorrect
10 divided by 4 leaves a remainder of 2, so 10 % 4 equals 2.
What is the result of 9 / 2 when both are integers?
✗ Incorrect
Integer division truncates the decimal, so 9 / 2 equals 4.
Which operator multiplies two numbers?
✗ Incorrect
The asterisk (*) is used for multiplication.
What happens if you divide an integer by zero in Java?
✗ Incorrect
Dividing an integer by zero throws an ArithmeticException at runtime.
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.