A good answer might be:

The answer is given below.

Increment Operator

The increment operator ++ adds one to a variable. Usually the variable is an integer type (byte, short, int, or long) but it can be a floating point type (float or double.) The two plus signs must not be separated by any character. Usually they are written immediately adjacent to the variable, as in the following:

int counter=0;

while ( counter < 10 )
{
  System.out.println("counter is now " + counter );
  counter++ ;
}

The increment operator can be used as part of an arithmetic expression, as in the following:

int sum = 0;
int counter = 10;

sum = counter++ ;

System.out.println("sum: "+ sum " + counter: " + counter );
It is vital to carefully study the following:
  • The counter will be incremented only after the value it holds has been used.
  • In the example, the assignment statement will be executed in the usual two steps:
    1. Step 1: evaluate the expression on the right of the "="
      • the value will be 10 (because counter has not been incremented yet.)
    2. Step 2: assign the value to the variable on the left of the "="
      • sum will get 10.
  • Now the ++ operator works: counter is incremented to 11.
  • The next statement will write out: sum: 10 counter: 11

Inspect the following code:

int x = 99;
int y = 10;

y = x++ ;

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

QUESTION 3:

What does the above program print?

Click Here after you have answered the question