It should say "extends the ForkJoinTask class", not inherits the interface. Errata noted.
The rest of the problem is fine as is. The idea is you have to know the difference between RecursiveTask and RecursiveAction to pick between B and C. Since the compute() method returns a value, C is the best choice candidate. You couldn't also have a compute() method that had a return type of void in a parent class, because this would violate rules for overriding, so B is not possible.
You assume the code does not compile but consider if MyTask includes a generic value in its inheritance structure. Can anyone construct a version of MyTask that would compile? Hint: it can be done in one line.
The rest is covered in the explanation in the solution guide.
I think you might be overthinking this one a little... the code compiles with the following implementation of MyTask:
As far as skipping RecursiveAction/RecursiveTask, that doesn't really match the text. For the fork/join framework, we use one or the other. The book (and the exam) expects you to use one of these two classes.
Note that the exam now uses the following disclaimer:
Assume the following:
Missing package and import statements: If sample code do not include package or import statements, and the question does not explicitly refer to these missing statements, then assume that all sample code is in the same package, and import statements exist to support them
Choice D contains a typo and doesn't make sense as written. It should say "The code produces an infinite loop at runtime not the code produces a ForkJoinPool at runtime.
Could I possibly suggest that you updated errata to have "Chapter 7 mock question" instead of current "Chapter 7" in Chapter column ? Some other errata records have it this way which makes it much easier to find information on the page.
posted 2 years ago
Please disregard my post above. I mixed up page numbers.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database