Test Your Knowledge: Quiz
Question 4-1. What is the difference between the = and == operators?
Question 4-2. Suppose I have four different variables, a, b, c, and d. What’s the shortest way to assign them all the value 36?
Question 4-3. What’s the difference between dividing two ints and dividing two doubles?
Question 4-4. What is the purpose of the % operator?
Question 4-5. What is the output of these operations?
4 * 8
(4 + 8) / (4 – 2)
4 + 8 / 4 – 2
Question 4-6. Let myInt = 25 to start. What is the value of myInt at each stage of the following code?
myInt += 5; myInt -= 15; myInt *= 4; myInt /= 3;
Question 4-7. Describe the difference between the prefix and postfix operators.
Question 4-8. Let x = 25 and y = 5. What do these expressions evaluate to?
(x >= y) (x >= y * 5) (x == y) (x = y)
Question 4-9. Let x = 25 and y = 5. What do these expressions evaluate to?
(x >= y) && (y <= x) !(x > y) !(x < y) && (x > y) ((x > y) || !(x < y)) && (x > y) ((x > y) && ((y < x) || (x > y))) && (x == y)
Question 4-10. Arrange these operators in order of precedence:
% != ?: && ++
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access