English

The output of a++ will be 1, if int a = -1. - Computer Applications

Advertisements
Advertisements

Question

The output of a++ will be 1, if int a = -1.

Options

  • True

  • False

MCQ
True or False

Solution

This statement is False.

Explanation:

  1. If int a = -1, then a++ is a post-increment operation. This means that the current value of a (which is -1) is used first, and then a is incremented by 1.
  2. So, the output of a++ will be -1 (the original value), and after this operation, a will become 0. 
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.04: Operators in Java - EXERCISES [Page 43]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.04 Operators in Java
EXERCISES | Q II. 2. | Page 43
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×