0
0
Javaprogramming~5 mins

Assignment operators in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AChecks if x equals 4
BMultiplies x by 4 and assigns the result to x
CDivides x by 4 and assigns the result to x
DAssigns 4 to x
Which operator assigns the remainder of division to a variable?
A/=
B-=
C+=
D%=
What is the result of int a = 10; a -= 3;?
Aa is 7
Ba is 13
Ca is 3
Da is 10
Which operator is used to assign a value to a variable?
A==
B+=
C=
D!=
What does x /= 5 do?
ADivides x by 5 and assigns the result to x
BMultiplies x by 5
CAdds 5 to x
DSubtracts 5 from x
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.