Recall & Review
beginner
What is the basic assignment operator in Java?
The basic assignment operator is
=. It assigns the value on the right to the variable on the left.Click to reveal answer
beginner
What does the operator
+= do in Java?The
+= operator adds the right-hand value to the left-hand variable and then assigns the result back to that variable. For example, x += 5 means x = x + 5.Click to reveal answer
beginner
Explain the difference between
= and == in Java.= is the assignment operator used to set a value to a variable. == is the equality operator used to compare two values to check if they are equal.Click to reveal answer
beginner
What does the operator
/= do?The
/= operator divides the left-hand variable by the right-hand value and assigns the result back to the variable. For example, x /= 2 means x = x / 2.Click to reveal answer
beginner
How does the
%= operator work in Java?The
%= operator calculates the remainder of dividing the left-hand variable by the right-hand value and assigns it back to the variable. For example, x %= 3 means x = x % 3.Click to reveal answer
What does the expression
x *= 4 do in Java?✗ Incorrect
x *= 4 means x = x * 4, so it multiplies x by 4 and stores the result in x.Which operator assigns the remainder of division to a variable?
✗ Incorrect
The
%= operator assigns the remainder of the division back to the variable.What is the result of
int a = 10; a -= 3;?✗ Incorrect
a -= 3 means a = a - 3, so a becomes 7.Which operator is used to assign a value to a variable?
✗ Incorrect
The
= operator assigns the value on the right to the variable on the left.What does
x /= 5 do?✗ Incorrect
x /= 5 means x = x / 5, dividing x by 5 and storing the result.Explain how compound assignment operators like
+= and *= work in Java.Think about how you can update a variable by combining math and assignment in one step.
You got /3 concepts.
Describe the difference between the assignment operator
= and the equality operator ==.One sets a value, the other checks if two values are the same.
You got /3 concepts.