wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array Reference" Watch "Array Reference" New topic
Author

Array Reference

Richard Rex
Ranch Hand

Joined: Sep 19, 2005
Posts: 100
Hi to all ranchers,

I'm just confused, I found this question from the Java Rule Round-Up Exam.

(#8) When you pass a reference to an array as an argument to a method call, you pass a NEW reference to the original array.

I answered false, because I think that it's not a NEW reference being passed but only a COPY of the reference. But it says its TRUE. But when I look at the explanation, it says "An array is an object, and Java always passes a COPY of the reference to the original object. Both references now point to the same array object." And I agree with the explanation, however, why is it TRUE?

I'm just really confused. Can anybody point out what I am missing out here?

Thanks!


"If you fail to plan, you plan to fail."<br /> <br />Chad<br />SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3<br />SCDJWS (next)
Ronnie Ho
Ranch Hand

Joined: Aug 10, 2005
Posts: 47
A copy of the reference is indeed a NEW reference, the object that it refers to is the same as the original one, but the reference itself is indeed new. The point of that question is "Copy of the reference is passed", not the reference itself, that's what it means by "New". Hope it helps.
 
GeeCON Prague 2014
 
subject: Array Reference