Computer Applications

What will be the output of a++, if int a= -1;?

  1. 1
  2. -1
  3. 0
  4. none

Java Operators

36 Likes

Answer

-1

Reason — a++ uses an increment postfix operator which works on the principle- 'Action then change'. Hence, first the value of a is printed and then it is incremented.

Answered By

9 Likes


Related Questions