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.