• Post Reply Bookmark Topic Watch Topic
  • New Topic

OCP Study Guide for 1Z0-809: Ch7, Review Question 9  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, about the review question 9 in Chapter 7: Answer  "C. MyTask inherits RecursiveTask." was marked as a correct answer, although it ambiguous, only probably true. So, may be a softer wording such as "may" or "can" "inherit RecursiveTask" would be in order?

Thanks.
 
author & internet detective
Marshal
Posts: 38248
623
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vesa,
It's not ambiguous. Here's why:
  • MyTask is passed as an argument to ForkJoinPool's invoke() method
  • The invoke method takes a ForkJoinTask parameter
  • There are four implementations of ForkJoinTask. AdaptedCallable and AdaptedRunnable are the first two, but they aren't on the exam (remember not to get distracted by extra knowledge). The remaining two are RecursiveAction and RecursiveTask.
  • RecursiveAction and RecursiveTask each have an abstract compute method that differs in return type. So it has to be RecursiveTask because FindMin returns a value from compute.


  • Does this help?
     
    Vesa Paatero
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi, thanks for your reply. My main point was that even though the API documentation of ForkJoinTask says "ForkJoinTask class is not usually directly subclassed," such subclassing is a possible thing to do, and therefore the conclusion that the instance of ForkJoinTask in the question is also an instance of RecursiveAction is "only probably true".

    The "Adapted" ones seem to be implementations not even mentioned in API documentation (a web search brought relevant links, though). Then there is CountedCompleter as another documented subclass.

    I admit this is probably not a topic where a busy person should put more time/effort. But thanks for your reply.

    Best Regards,
    Vesa
     
    If you're gonna buy things, buy this thing and I get a fat kickback:
    Rocket Oven Kickstarter - from the trailboss
    https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!