Uniary increment and decrement operators in bluej
What will be the output
a)Int x=5;
X++;
System.out.println(x);
b)int x=5;
Int y=x++;
System.out.prinrln (y);
Answers
Answered by
1
x++ means use and then change the value of x.
a) The answer will be 6 (Here it is asked to give the output of the changed value)
b) y=5. (Here y stores the value before the value of x is being changed)
a) The answer will be 6 (Here it is asked to give the output of the changed value)
b) y=5. (Here y stores the value before the value of x is being changed)
Answered by
0
(a) Given int x = 5.
x++;
System.out.println(x);
Output: 6.
(b)
Given int x = 5;
int y = x++;
System.out.println(y);
Here, u first assign the value of x to y and then increment the value of x.
Output: y = 5, x = 6.
Hope this helps!
x++;
System.out.println(x);
Output: 6.
(b)
Given int x = 5;
int y = x++;
System.out.println(y);
Here, u first assign the value of x to y and then increment the value of x.
Output: y = 5, x = 6.
Hope this helps!
siddhartharao77:
Gud Luck!
Similar questions