• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Garbage Collector?

 
Greenhorn
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?

Thanks,

Ricky
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic