KnowledgeBoat Logo

ICSE Class 8 Computers Differentiate Between the Following

Distinguish between Prefix and Postfix operator

Java Operators

ICSE

24 Likes

Answer

Prefix OperatorPostfix Operator
It works on the principle of CHANGE-THEN-USE.It works on the principle of USE-THEN-CHANGE.
It is written before the operand.It is written after the operand.
Example:
int a = 99;
int b = ++a;
After the execution of these two statements, both a and b will have the value of 100.
Example:
int a = 99;
int b = a++;
After the execution of these two statements, a will have the value of 100 and b will have the value of 99.

Answered By

15 Likes