exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 89 discussion

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

Given:



and



Which statement is true?

  • A. The memory allocated for Jack object can be reused in line 2.
  • B. The memory allocated for Jane object can be reused in line 1.
  • C. The memory allocated for Jane object can be reused in line 2.
  • D. The memory allocated for John object can be reused in line 1.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
ASPushkin
7 months, 1 week ago
Selected Answer: D
answer: D A Failed createPerson() returns reference to Jack next line is a line 2 B Failed createPeople() returns Jane next line is a line1 C Failed createPerson() returns Jack with Jane as a parent D Correct createPeople() returns Jane and reference to John is missed
upvoted 1 times
...
cathDev
9 months, 3 weeks ago
Selected Answer: A
At line 1, before the createPerson method is called, jane is referenced by person. After the method call, person references Jack, and jane is now the child of Jack. Since Jack is still referenced by person, its memory cannot be reused at this point. However, if person were to be reassigned again to another object or set to null, the memory allocated for the Jack object could potentially be reclaimed by the GC, as there would be no more references to it, making it eligible for garbage collection and memory reuse.
upvoted 1 times
...
d7bb0b2
1 year ago
D is correct. Because jhon no have more references in the code so is elegible for GC C is not, because Jhon contain a reference to jane so cannot be elegible for GC and his memory cannot use in line 2.
upvoted 1 times
d7bb0b2
1 year ago
Does not matter if jhon contain jane child, as this object no is used after the createPeople method is elligible for GC so D is correct
upvoted 1 times
...
...
[Removed]
1 year, 5 months ago
Selected Answer: D
Pretty sure the correct answer is D. Since the John Object is created and not returned by the createPerson() method. So John is ready to be garbage collected right after exiting the method.
upvoted 4 times
...
Stavok
1 year, 6 months ago
Selected Answer: C
createPeople() method, a Person object named jane is created and returned. This object is then passed to the createPerson() method, where a new Person object named Jack is created with jane as its child. The reference to the jane object is then overwritten by the reference to the new Jack object when it is returned from the createPerson() method and assigned to the person variable in the main() method. Since there are no more references to the jane object after this assignment, its memory can be reused by the garbage collector in line 2. C is correct
upvoted 1 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