Is subtracting one from a variable a common operation?

A good answer might be:

Yes. Minus one if you got this wrong.

Decrement Operator

There is a postfix and a prefix decrement operator. The postfix operator decrements a variable after using it; the prefix operator increments a variable before using it.

ExpressionOperationExampleResult
x++ add one after useint x = 10;
int y;
y = x++ ;
x is 11; y is 10
++x add one before useint x = 10;
int y;
y = ++x ;
x is 11; y is 11
x-- subtract one after useint x = 10;
int y;
y = x-- ;
x is 9; y is 10
--x subtract one before useint x = 10;
int y;
y = --x ;
x is 9; y is 9

Inspect the following code:
int x = 99;
int y = 10;

y = --x ;

System.out.println("x: " + x + "  y: " + y );

QUESTION 8:

What will this fragment write out?

Click Here after you have answered the question