programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

javaranch model exam Q #107

Greenhorn
Posts: 1
• Number of slices to send:
Optional 'thank-you' note:
#107 Assume x = 0 and y=3. what is the value of x after x=y++;
I think the above answer is not correct.
x value is 4 and y is 3 after x=y++ is executed.

Ranch Hand
Posts: 36
• Number of slices to send:
Optional 'thank-you' note:
The given answer of x = 3 and y = 4 is correct.
In the expression "y++ ", ++ is used as a post increment so x is first assigned the value of y (ie 3) then y is incremented (ie to 4).
You would be correct if the expression used the ++ as a preincrement (ie x = ++y

Greenhorn
Posts: 28
• Number of slices to send:
Optional 'thank-you' note:
Hi,
can u mail the link to this javaranch mock test site??
thanks maha

Originally posted by shaik abdulla:
#107 Assume x = 0 and y=3. what is the value of x after x=y++;