after line 11, nobody referencing to s1, thus makes s1 gc eligible.
Even though s2 is null, it is not eligible for gc, because s3 still pointing to it. S3 is not eligible for gc because s1 is pointing to it. Only object that nobody pointing to is S1.
After line 11 only one object is eligible for GC = S1.
No. s1, s2, s3 are just variable that has Object's reference value(=address value). they are not Object. you said "nobody referencing to s1". that's incorrect.
-> "Nobody is referencing the object that s1 initially had." is correct.
Only the object refered by s2 is lost.
at line 9 s1 original referenced object is gone. it points to s3.
at line 10 s3 original referenced object is gone. it points to s2
at line 11 s2 original referenced object is gone. it point to null. s2 is garbage collected.
where as s3 and s1 are still referencing valid objects in memory
The correct answer is the letter A, the reason is that the 3 variables are local variables, so their scope is inside the main method, after line 11 it leaves the main method and the 3 variables lose their usability because they leave their scope , so all 3 are eligible to enter the Garbage collector.
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Harid
Highly Voted 4 years, 1 month agoJongHwa
2 years, 11 months agohemassridhar
Highly Voted 4 years, 9 months agoabhayshitole
Most Recent 1 month, 2 weeks agoyyfabc
1 year, 6 months agoRAADEL3IMLAK
1 year, 8 months agoakbiyik
1 year, 10 months agocarloswork
1 year, 11 months agoiSnover
2 years agoludaka
7 months, 2 weeks agoarcher1903
2 years, 4 months agobiggeek123
2 years, 9 months agobrianhuang881215
3 years, 1 month agobshailesh3
4 years, 8 months agokrkpnr
4 years, 7 months ago