Primitive Types
If an integer variable count
equals -4 and we perform the operation count += ++count; what will be the final value of count?
-3.
-7.
-6.
-8.
What theoretical implications could changing all applicable increment (++
) statements within loops iterating over complex data structures into their equivalent addition-assignment (+=
) counterparts have on readability and maintenance?
INCORRECT_wrong_answer_83
Readability may decrease if increment semantics provide clearer intent than addition-assignment analogs particularly with nested structures or algorithms relying heavily on index manipulation.
Which of the following is the compound assignment operator for multiplication?
/=
-=
*=
+=
If int array[] = {5,10,15}, which index will change incorrectly using shorthand operators?
array[0] /= array[array.length / (array[0] / array[0])];
arrray [array.length -11 <<=array [o]/arrary[o]);
array[2] *= array[0]++;
arrray[1] += --array[0];
After applying composite assignment operator, how will you present the original value change given an integer 'num' equals eight and expression 'num += 3 * num - 1'?
num equals twenty-five
num equals forty-nine
num equals twenty-seven
num equals thirty-one
What will be the result of applying this sequence of compound assignments if int variables x=10 and z=5 initially?
Value of z doubles while x remains unchanged.
Value of x increases while z decreases.
Value of x becomes zero while z triples.
Both values become equal.
Which of the following scenarios is an example of using a compound assignment operator?
total *= discountRate
count = count / divisor
price = price + tax
subtotal = subtotal - discount

How are we doing?
Give us your feedback and let us know how we can improve
When using a compound assignment operator in a for-loop to decrement a counter by half its current value each iteration, which initial counter value would require more iterations to reach less than one - starting with either counter =400
or counter =800
?
Starting with counter =800.
It is impossible to determine without knowing the exact values of each iteration.
Starting with counter =400.
Both will take the same number of iterations.
Which statement correctly uses a compound assignment operator to halve the value of an integer variable 'num'?
num /= 2;
num += 2;
num -= 2;
num *= 2;
What is the value of z after the following code is executed? int z = 5; z++; z += 2;
2
8
5
7