File APIs for Java Developers Manipulate DOC, XLS, PPT, PDF and many others from your application. http://aspose.com/file-tools
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of Java Interview Guide this week in the Jobs Discussion 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++;