This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!See this thread for details.
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of Refactoring for Software Design Smells: Managing Technical Debt this week in the OO, Patterns, UML and Refactoring forum!

# javaranch model exam Q #107

shaik abdulla
Greenhorn

Joined: Sep 02, 2000
Posts: 1
#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.
daryl olson
Ranch Hand

Joined: Aug 15, 2000
Posts: 36
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

Joined: Aug 28, 2000
Posts: 28
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++;