aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock Exam from Bill Brogden Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock Exam from Bill Brogden" Watch "Mock Exam from Bill Brogden" New topic
Author

Mock Exam from Bill Brogden

Maria Garcia
Ranch Hand

Joined: Jul 14, 2002
Posts: 86

What happens when a program calls the Result method with a value of 30 ? The answer is 30
Question:
Shouldn't it be 31 ?


SCJP 1.4
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
X is passed on as N. After that X is a local variable and so any changes made in N does not reflect in X.


Sunita<br />SCJP 1.4
Maria Garcia
Ranch Hand

Joined: Jul 14, 2002
Posts: 86
hmmm, i thought N and X were referring to the same object when it was passed to method Increment. I'm still confused.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
We start out with one object pointed to by X. Next we pass that one object to a method. We now have one object pointed to by X and N. Next we create a brand new object and have N point to it.
Now we have two objects. One pointed to by N and another pointed to by X.
When we get back to the result() method, X is still pointing to the original object, not the new object that N was pointing to.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Maria Garcia
Ranch Hand

Joined: Jul 14, 2002
Posts: 86
Thanks sun, Thomas!
Now I get it!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Yaknow, I do respond to reader email so you could have asked me.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Exam from Bill Brogden
 
Similar Threads
Confused help
wrapper
Explaining output regarding static methods
Pass By Value Example
Displaying the largest and smallest of three integers