Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes javaranch model exam Q #107 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "javaranch model exam Q #107" Watch "javaranch model exam Q #107" New topic
Author

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++;
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

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
MahaAdd
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++;
Answer :3
I think the above answer is not correct.
x value is 4 and y is 3 after x=y++ is executed.

 
Consider Paul's rocket mass heater.
 
subject: javaranch model exam Q #107