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?
About Question enthuware.ocpjp.i.v11.2.919 :
Moderator: admin
-
- Posts: 34
- Joined: Sat Jun 06, 2020 4:51 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.919 :
>>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?
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?
-
- Posts: 34
- Joined: Sat Jun 06, 2020 4:51 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.919 :
Hello, Aren't your two statements contradicting one another?
Here you said to not assume any code outside of this piece of code:
Here you said to assume the possibility of a caller outside of this piece of code:
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:
Also, the keyword in the question is after, so yes, I had to assume cases where another caller uses it or not.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?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.919 :
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.
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.
Who is online
Users browsing this forum: No registered users and 3 guests