About Question enthuware.ocpjp.i.v11.2.919 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
dimitrilc
Posts: 34
Joined: Sat Jun 06, 2020 4:51 pm
Contact:

About Question enthuware.ocpjp.i.v11.2.919 :

Post by dimitrilc »

Hello, I think all three options,

//4,
never in this method,
and Cannot be determined

are all correct answers since we don't know whether Object XXX is still being used by other parts of the code or not.

Or is it a fact that if an object is returned by a method, it can never be garbage collected?

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.919 :

Post by admin »

>>are all correct answers since we don't know whether Object XXX is still being used by other parts of the code or not.
The question is above the code given in the problem statement. You need to consider only what happens in that code.

>>Or is it a fact that if an object is returned by a method, it can never be garbage collected?
If an object is being returned by a method then it cannot be garbage collected in that method. If it is garbage collected in that method, how will it be returned to the caller?

dimitrilc
Posts: 34
Joined: Sat Jun 06, 2020 4:51 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.919 :

Post by dimitrilc »

Hello, Aren't your two statements contradicting one another?

Here you said to not assume any code outside of this piece of code:
The question is above the code given in the problem statement. You need to consider only what happens in that code.

Here you said to assume the possibility of a caller outside of this piece of code:
If an object is being returned by a method then it cannot be garbage collected in that method. If it is garbage collected in that method, how will it be returned to the caller?
Also, the keyword in the question is after, so yes, I had to assume cases where another caller uses it or not.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.919 :

Post by admin »

The problem statement shows just a method. So, obviously, there is got to be code in which this method exists. Between the two options, the "Cannot be determined." option cannot be correct because you know that it cannot be GCed in this method! Therefore, given that you have to select only 1 option, "Never in this method." is the better option.

I would suggest you to go with the most reasonable interpretation than wasting time splitting hair. You have to allow for a little bit of subjectivity and apply common sense. Otherwise, you may end up spending more time over-analyzing. But it is up you.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests