File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage collection Problem" Watch "Garbage collection Problem" New topic

Garbage collection Problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Given the code. Which line of code marks the earliest point that an object referenced by myInt becomes a candidate for garbage collection?

A) Line 4
B) Line 5
C) Line 6
D) Line 7
Correct answer:7

i think answer should be line 4
first, myint---->new Integer(0) //first object
myint------>new Integer(1)

so on till ----> new Integer(4)

so after first object would be eligible for GC line 4

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
after line 4 myint is assigned to arr[i] at line 5 so object reffered by myint has another reference at line 5 and hence it cant be GCed until the method has completed.

SCJP 1.6 96%
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634


i have exam on 15th
can you give any tips ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15100

Once again, please QuoteYourSources.

What does "scjptest" mean? Is this from the actual exam?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Garbage collection Problem
jQuery in Action, 3rd edition