0
About Java McQ
How print(++x = x++) is false It should be the same result? Doesn’t it?
7 Respostas
+ 3
No, assuming <x> is a number, ++x doesn't equal x++ because these operators have different way of working
++x increments in-place (immediately)
x++ increments after the current line has been evaluated by Java compiler
For less confusion in reading a code, it is NOT recommended to mix the use of these operators in a single line of code, the code looks more of a riddle than an actual code when it's being written that way.
+ 3
Mustakim Rahman
int x = 7
x++ == ++x;
In this case result would false because of (x++)
x++ = 7 but after increment x would be 8
but ++x here is preincrement so ++x = 9 because x was already 8
+ 2
Mustakim Rahman
int x = 7;
++x = 8 and x++ = 7;
but in this case ++x == x++;. after increment of x (++x) , x++ would be 8 so 8 == 8 true
System.out.println (++x==x++) = true
+ 1
Yes brother i just forget to text properly, (++x == ++x) …
Sometimes in the mcq part wrong answere are the correct answere. Very Frustrating!
+ 1
Ipang
Suppose int x=7;
x++; or ++x;
What would be the output?
7 or 8?
0
Mustakim Rahman
Paste this inside a class' main method, I think you'll understand the difference afterwards
int x = 7;
System.out.println("x++ = " + x++);
System.out.println("After line evaluation <x> = " + x);
x = 7; // reset <x> value to start over
System.out.println("\n++x = " + ++x);
System.out.println("After line evaluation <x> = " + x);