• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Barry Boones Exam Doubt

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 13: There are a number of labels in the source code below. These are labeled a through j. Which label identifies the earliest point where, after that line has executed, the object referred to by the variable first may be garbage collected?


Select the one right answer.

a.d: (What The Awnser Is)
b.e:
c.h:
d.i:
e.j: (what I think)

Can anyone explain me why ,i have read the explaination given by Boone but couldnt get it.

i think its last line j: becuase although variable first is nulled at line d: but its refernce is still holded by line c: by the variable riddle.

Thanks,
With Regds,
Anand.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
riddle holds a new String (immutable) object = "When is a <arg0>", riddle does'nt hold a reference to "When is a " and a reference to first.

riddle = "When is a " + first
is equivalent to
riddle = "When is a ".concat(first), which creates a new String.

There's no more reference to the String created at (a) after first=null.
[ October 03, 2005: Message edited by: Seb Mathe ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic