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.
Izzy programs a loop with int i = 0; i <= 10; i += 2;
. How many loop iterations will occur before it completes?
12
6
10
8
After executing "number /= divider;", what happens if divider is zero?
number becomes infinity.
number remains unchanged.
number becomes zero.
An ArithmeticException occurs.
Which of the following is the compound assignment operator for multiplication?
/=
-=
*=
+=
Given an initially declared double variable balance = 1000.0
, which code segment incorrectly applies a compound assignment operator to decrease balance by a monthly fee of $9.99?
INCORRECT 3. balance =-9.99;
INCORRECT 2. balance = balance -9.99;
CORRECT. balance -=-9.99;
INCORRECT 1. balance -=9.99;
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];

How are we doing?
Give us your feedback and let us know how we can improve
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 is the result of x
after executing the following code snippet if x
is initially set to 10? x *= 2;
x becomes 20.
x remains unchanged.
x becomes undefined.
x becomes 5.
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;