javamethodsabstract

Difference between Hooks and Abstract Methods in Java


This is a quoted question from the study materials from my university.

It makes totally no sense to me.

For me hooks are specified points in (mostly sequential but not only) programs, where you can specify your own methods or callbacks to be executed.

For example an application has an "on before shutdown hook", i can register my callback method there that saves the user data to disk before shutdown.

Abstract methods are self explaining.

To me this is something completely different? or does either of those things have a 2nd meaning I don't know of? I did a quick search but didn't find anything.


Solution

  • Personally, I would go to the professor and ask for clarification before asking the StackOverflow community.

    ...but, that being said, I believe (if your description of a hook is correct) that any class can register a callback method for a hook whereas an abstract method forces a child class a to implement its own algorithm for the given method.