About Question enthuware.ocpjp.v11.2.3656 :

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

Moderator: admin

Post Reply
enthjo
Posts: 1
Joined: Sun Mar 21, 2021 2:05 pm
Contact:

About Question enthuware.ocpjp.v11.2.3656 :

Post by enthjo »

Just ran through a test with this question and it contains an error. In this question - the method call on line //6 does not have the parameter of Buddy[] therefore it doesn't compile so the answer should be 0, not 1.

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

Re: About Question enthuware.ocpjp.v11.2.3656 :

Post by admin »

You are right, it should be initBuddies(ba). Fixed.

thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Pl4cek
Posts: 1
Joined: Sun Apr 11, 2021 4:07 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3656 :

Post by Pl4cek »

I believe there's an issue with the explanation for this question

Code: Select all

        ba[0] = ba[1]; //3
        ba[1] = ba[2]; //4
and

Code: Select all

Buddy[] ba = new Buddy[3]
In the explanation is states:
4. At //4, ba[2] is set to ba[3] but ba[3] is null. Therefore, ba[1] is also null after this line.

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

Re: About Question enthuware.ocpjp.v11.2.3656 :

Post by admin »

You are right. It should be:

1. new Buddy[3] creates an empty array of length 3. No Buddy object is created here and each element of the array points to null.

2. One Buddy object is created at each of the lines //1 and //2.

3. At //3, ba[0] is made to point to the same object as the one pointed to by ba[1]. Therefore, nobody is now pointing to the original Buddy object pointed to by ba[0]. It is therefore eligible for GC now. However, there are two references to the second Buddy object (i.e. ba[0] as well as ba[1] are now pointing to the same Buddy object).

4. At //4, ba[1] is set to ba[2] but ba[2] is null. Therefore, ba[1] is also null after this line.

Therefore, at the end of the initBuddies method, only one Buddy object is eligible for GC.
Fixed.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests