Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
Sheriff
Posts: 38571
661
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
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!