Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Rule Round-up #8

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The wording of Question #8 is not very clear. It says:
When you pass a reference to an array as an argument to a method call, you pass a new reference to the original array.(True or False)
You actually pass a copy of the reference and not a new reference.
 
Trailboss
Posts: 23209
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#8: TRUE or FALSE: When you pass a reference to an array as an argument to a method call, you pass a new reference to the original array.
The answer is: TRUE - 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.
Hmmm, changing this to "you pass a copy of the reference..." might be a good idea.
Anybody else?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it is clearer the second way. I think the first is OK, but the word "new" has mixed connotations which it's best to avoid.
 
paul wheaton
Trailboss
Posts: 23209
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made the change.
 
    Bookmark Topic Watch Topic
  • New Topic