exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 180 discussion

Actual exam question from Oracle's 1z0-808
Question #: 180
Topic #: 1
[All 1z0-808 Questions]

Given the code fragments:

And:

Which statement is true?

  • A. After line 11, three objects are eligible for garbage collection.
  • B. After line 11, two objects are eligible for garbage collection.
  • C. After line 11, one object is eligible for garbage collection.
  • D. After line 11, none of the objects are eligible for garbage collection.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
UAK94
Highly Voted 2 years, 3 months ago
B is correct. After line 11 -> 2 objects are eligible for GC. After line 12 -> 3 objects are eligible for GC.
upvoted 6 times
...
MPignaProTech
Most Recent 2 months, 3 weeks ago
Selected Answer: B
s3 and s1 are eligibale for garbage collector. B is correct
upvoted 1 times
...
BelloMio
7 months, 1 week ago
My previous answer is incorrect. Scrap that.
upvoted 1 times
...
BelloMio
7 months, 1 week ago
We have 3 Student objects initially. first is reachable by S1 Second is reachable by S2 Third is reachable by S3 When we either nullify the reference or reassign it, we make it unreachable. There are generally four ways to make an object eligible for garbage collection. https://www.geeksforgeeks.org/garbage-collection-java/ Nullifying the reference variable Re-assigning the reference variable An object created inside the method Island of Isolation We are in the reassignment S1 = S3, we just made the object that had reference variable of S1 unreachable S3 = S2, we just made the object that had reference variable of S3 unreachable S1 = S2, we just made the object that reference variable of S1 unreachable. This object was the same as above. So in total, we have 2 objects eligible for garbage collection.
upvoted 1 times
...
ShaileshRaj
1 year, 3 months ago
Selected Answer: B
3 objects are created and at the end only S2 is being referenced other S1 and S2 has no reference. So answer is 2 objets are eligibe for garbage collection
upvoted 2 times
...
RAADEL3IMLAK
1 year, 11 months ago
answer is B
upvoted 2 times
...
akbiyik
2 years, 1 month ago
Selected Answer: B
Answer is B.
upvoted 3 times
...
carloswork
2 years, 1 month ago
Selected Answer: B
Answer is B.
upvoted 2 times
...
iSnover
2 years, 3 months ago
Selected Answer: A
The correct answer is letter A, an object is eligible for the garbage collector when it is no longer being used, as after line 11 no object is being used, the 3 are elected for the garbage collector. Even though "s2" can still be accessed, then on line 11 its scope is over so it is also elected to the garbage collector.
upvoted 3 times
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago