About Question enthuware.ocpjp.v7.2.1241 :

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

Moderator: admin

Post Reply
krohani
Posts: 31
Joined: Tue Oct 06, 2015 1:57 pm
Contact:

About Question enthuware.ocpjp.v7.2.1241 :

Post by krohani »

I understand why answer choices 4 and 6 are correct but I do not understand why answer choice 1 is wrong? Is it because there is no requirement to return any value and therefore RecursiveTask is not optimal?

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

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by admin »

Since the question is about the most correct approach, RecursiveTask is not as suitable as RecursiveAction. Yes, although not by much, a RecursiveTask will be at least an instruction slower than RecursiveAction because it returns a value, which is not required here.

HTH,
Paul.

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by sumanenthu »

But on contrary to this question if we look at question no - enthuware.ocpjp.v7.2.1238, on the line 15 it's saying that invokeAll is the correct method to call. But going through this question it seems that we should use compute for one part and fork the other part and then join them back. What am I missing ?

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

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by admin »

They are showing two different approaches. If you have subdivided the tasks and if you want to do something only after all the subtasks are done, then you should use invokeAll because invokeAll will join on those tasks i.e. you will be waiting until all the tasks are done. invoke is works similarly for one task.

Basically, invoke/invokeAll method include the functionality of fork+join.

Explanations of 2.1241 or 2.1338 do not say one is the correct approach and one is wrong. Both are different approaches and they can be used as per situation.

HTH,
Paul.

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by sumanenthu »

So, I understood as if I use invokeall() even for two tasks, its the same thing as doing fork and joining them explicitly.

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by sumanenthu »

Could you please specify some good resource to clear the concepts of ForkJoinPool correctly?

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

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by admin »

You should start with the Oracle's official trail:https://docs.oracle.com/javase/tutorial ... kjoin.html
this one is good as well: http://tutorials.jenkov.com/java-util-c ... npool.html

sumanenthu
Posts: 23
Joined: Sun Feb 21, 2016 10:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by sumanenthu »

Thanks. Please check my 4th reply on this post from bottom.

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

Re: About Question enthuware.ocpjp.v7.2.1241 :

Post by admin »

sumanenthu wrote:Thanks. Please check my 4th reply on this post from bottom.
Yes, but I would suggest you to write a sample program and verify that.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests