File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javaranch model exam Q #107

 
shaik abdulla
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#107 Assume x = 0 and y=3. what is the value of x after x=y++;
Answer :3
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
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
MahaAdd
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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++;
Answer :3
I think the above answer is not correct.
x value is 4 and y is 3 after x=y++ is executed.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic