Font size
WorksheetsJava Increment & Decrement Operators
Total questions: 10
Worksheet time: 6mins
++ increases the value of a variable by 1
assignment operator
decrement operator
increment operator
sentinel
--; decreases the value of a variable by 1
assignment operator
decrement operator
increment operator
sentinel
PRE-increment us used when you want to use the incremented
value of the variable in that expression. Whereas POST-increment uses the original value before incrementing it
True
False
What would the new value of A be?
A=1;
a++;
1
2
3
4
What would the new value of A be?
A=1;
A--;
0
1
2
-1
What's the value of below?
int i=5;
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
5
6
7
6
6
7
6
7
8
5
5
6
++i and i++ cannot be used anywhere for the same purpose
true
false
What does the following code output?
int x = 1;
System.out.println(x++);
1
2
compilation error
runtime error
Which statement(s) are equivalent to i = i + 1?
i += 1
i++
i -= 1
i--
else x--;
else if (x < 0) x--;
if (x < 0) x--;
else x = 0;
else x++;
x--;
