Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Certification
»
Programmer Certification (OCPJP)
Garbage collection?
srikanth reddy
,
Ranch Hand
Sep 22, 2005 03:17:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Problem After which line will the object created at line XXX be eligible for garbage collection? public Object getObject(Object a) //0 { Object b = new Object(); //XXX Object c, d = new Object(); //1 c = b; //2 b = a = null; //3 return c; //4 } Options Select 1 correct option. 1)//2 2)//3 3)//4 4)Never in this method. 5)Can't say.
here i thought the answer to be 2..
but its not ...can anyone explain me when does the object gets garbage collected exactly??
srikanth
Srinivasa Raghavan
,
Ranch Hand
Sep 22, 2005 03:21:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Never in that method . Answer 'c' because , eventhough 'b' is set to null
the reference variable c points to this object and it is returned to the calling place.
[ September 22, 2005: Message edited by: Srinivasa Raghavan ]
Lalitha Gottumukkula
,
Ranch Hand
Sep 22, 2005 03:29:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Because it is having direct reference (c), it is never garbage collected.
srikanth reddy
,
Ranch Hand
Sep 22, 2005 03:31:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
yes srinivas,
got it ..thanks for your help
Post by:
autobot
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 682 times.
Similar Threads
GC
GC ??
garbage collection
Unfair Question on JQ
GC
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:02:05
.