• 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

Sun Sample queston #3

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
SAMPLE QUESTION 3:
1.public class X {
2. public void m(Object x) {
3. x = new Integer(99);
4. Integer y = (Integer)x;
5. y = null;
6. System.out.println("x is" + x);
7. }
8.}
When is the Integer object, created in line 3, eligible for garbage collection?
1.never
2.just after line 4
3.just after line 5
4.just after line 6 (that is, as the method returns)
5.when the calling method sets the argument it passed intothis method to null
Answer: 4
Mukti


[This message has been edited by Mukti Bajaj (edited January 22, 2001).]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you passed in the parameter "Object x" it becomes a variable local to the method. Local variables only live as long as the method lives. After that - too bad - they are food for the garbage collector!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic