1. Java uses (==) to test if the value on the left is equal to the value on the right and (!=) to test if two items are not equal.
2. ____________ assignment operators (+=, -=, *=, /=, %=) can be used in place of the assignment operator
3. Consider this statement: a = a+6; In Java this can also be written as:
4. The increment operator (++) and decrement operator (--) are used to___ 1 or _____1 from the stored value of a variable or an array element.
5. Compound operators, also called combined assignment operators, are a __________ way to update the value of a variable.
6. What does the following compound assignment operator do? -=
7. What does the following compound assignment operator do? %=
8. What does the following compound assignment operator do? &=
9. What does the following compound assignment operator do? >>=
10. What does the following compound assignment operator do? |=
11. What is the final value of i?
12. What is the final value of a?
int a = 2;
int b = 3;
a *= b + 1;
13. A binary operator will always have exactly two operands. However, sometimes one or both operands of a binary operator is a subexpression.
14. Name the constant that is being used in this program.
public class CalculateTax
{
public static void main ( String[] arg )
{
final double DURABLE = 0.045;
final double NONDURABLE = 0.038;
. . . . . .
}
}
15. Which of the following is an advantage of using a constant (as has been done in the above question) in your program?
16. Which of the following has the highest operator precedence?
17. Which of the following has the highest operator precedence?
18. The Modulus operator is often used, as is the case in this example, to ________________________________.
19. MOD can also be used to _______________________________.
21. This code sets x to z * 2 (4), y to y divided by 2 (5 / 2 = 2) and z = to z + 1 (2 + 1 = 3).
22. This code subtracts one from x, adds one to y, and then sets z to to the value in x - y minus the current value of y.
23. x += y is the same as:
24. x *= y is the same as x = x * y
25. x = / y is the same as x = x / y.