• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sybex OCP Java 8 Study Guide Chapter 7 Assessment question 9

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have two issues with this question and the related answer:
1/
The question states "MyTask extends ForkJoinTask" then in the possible answers:

B. MyTask inherits RecursiveAction.
C. MyTask inherits RecursiveTask.

And in the answers it is said that C is correct.  But C is not correct. Both RA and RT extend FJT. Just because MyTask extends FJT does not mean it inherits either RA or RT. It's just another subclass of FJT, as are RA and RT.
In looking at the documentation I see that compute is defined in RA and RT but fork and join are defined in FJT. You can submit a FJT to a ForkJoinPool but you can't then call compute on a FJT although you can call fork and join.

2/
Also in the question, D is said to be incorrect:

D. The code produces a ForkJoinPool at runtime.

Why is this? In the code there is the line:

ForkJoinPool pool = new ForkJoinPool(1);

which obviously creates a new FJP.

I am confused by both these issues; I am fairly certain of my read of it but am happy to be corrected.
Thanks.
SS

 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have a copy of that book; please quote the full questions.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steven Squeers wrote:And in the answers it is said that C is correct.  But C is not correct. Both RA and RT extend FJT. Just because MyTask extends FJT does not mean it inherits either RA or RT. It's just another subclass of FJT, as are RA and RT. In looking at the documentation I see that compute is defined in RA and RT but fork and join are defined in FJT. You can submit a FJT to a ForkJoinPool but you can't then call compute on a FJT although you can call fork and join.


The question is implying that MyTask extends one of RecursiveAction or RecursiveTask. (granted not clearly enough). It's more of a what can be true. It isn't possible for it to be a RecursiveAction because of the non-void return type.

Steven Squeers wrote:
Also in the question, D is said to be incorrect:

D. The code produces a ForkJoinPool at runtime.

Why is this? In the code there is the line:

ForkJoinPool pool = new ForkJoinPool(1);

which obviously creates a new FJP.


For Option D, we meant "and completes successfully". The infinite loop prevents it from being successful.
 
Steven Squeers
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I see, thank you.
 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic