English

If a = 12, give the value of the following expression: (a++)--;

Advertisements

Question

If a = 12, give the value of the following expression:

(a++)--;

Short Answer
Advertisements

Solution

Given: a = 12

Expression: (a++)--

The post-increment operator (a++) produces a value, not a variable. The post-decrement operator (--) cannot be applied to this value.

Therefore, the expression causes a compilation error in Java.

  • Value of expression ((a++)--) = Compilation error
  • New value of a = Not applicable (program does not compile)
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 135]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 59. (c) | Page 135
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×