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

Garbage Collector?

Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have doubt on this question

In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:

1: public class Test {
2: public static void main (String args []) {
3: Employee e = new Employee("Bob", 48);
4: e.calculatePay();
5: System.out.println(e.printDetails());
6: e = null;
7: e = new Employee("Denise", 36);
8: e.calculatePay();
9: System.out.println(e.printDetails());
10: }
11: }

answer : Line 7

Why its line 7 not line 6?


Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic