• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Dan's Exam Array Doubt

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI All,
Can't understand the output of the question of following questions.
in
Method Arguments
Exam 1
Any further explanation to make it more clear ??

Answer
9 a Prints: 1,1 Although the reference parameter i1 is reassigned inside of m1, the change has no impact outside of m1. Array references are passed by value: the invoked method gets a copy of the array reference.
and

Answer
11 d Prints: 3,1 Inside of method m2, the local variables i1 and i2 remain unchanged while the shadowed instance variables are changed.
Thanks in advance,
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Question 9:
i1 passed in method m1 is a "local copy" of i1 in method m1.Any operation on it will not effect the m1 of Class GFC306 out side the method.But i2 is different,as there is not a variable named i2,this.i2(the class variable )will be used.
In Question 11:
pay atention in "this" means the class itsself
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic