About Question enthuware.ocajp.i.v7.2.919 :

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

Moderator: admin

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

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by admin »

yes, right.
If you like our products and services, please help us by posting your review here.

shambhavi
Posts: 25
Joined: Fri Aug 04, 2017 12:21 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by shambhavi »

thanks ! :joy:

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by Sergey »

Once a method returns all the variables that it created are gone. The stack space (where all the automatic variables are kept) is cleared up and reclaimed. So there is no question of a variable hanging on to an object after the method returns.
based on this explanation (from another question 7.2.921) i should think that object can be garbage collected after "return" statement i.e. after line 4.
Where am i wrong?

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

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by admin »

The variables of this method are indeed gone after the method returns. But in this case the return statement returns the reference to the object to the caller.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by flex567 »

Why is answer nr. 5 not a correct option?

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

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by admin »

Because it can be determined the object can never be garbage collected in this method. Option 4 and 5 are contradictory. So, if 4 is correct, 5 cannot be correct.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by flex567 »

Had there been no Option 4, The Option 5 would be correct ?

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

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by admin »

In that case, yes.
If you like our products and services, please help us by posting your review here.

ethanaidenies
Posts: 1
Joined: Thu Dec 20, 2018 6:54 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.919 :

Post by ethanaidenies »

Hi,I get your point @inaelrodrigues. Honestly,
I chose the same answer.
For me, after line 3, the references a, b and c point to null, so the object itself is eligible for garbage collection from that point (line 3) and not later.

Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests