13
seeba
6y

This book be like

Friend: Can you explain this?
I(clueless): Sure ...

Comments
  • 11
    Its a class that cannot be instantiated (new className())

    Its like an interface but you can have functional methods on an abstract class.

    Non functional methods must have no body and the modifier "abstract" on the method declaration: public abstract double methodName();

    Its a "contract" (as well as interfaces) to concrete (non-abstract) subclasses that assure they will implement the abstract methods but will also have the functionality of the concrete methods.

    Hope it helps and if anything is wrong or missing, please correct me :)
  • 2
    @azous Approved!
  • 1
  • 1
    @azous in addition:
    An abstract class can use its own abstract functions as if they are implemented, because all concrete classes deriving it have to override the abstract functions.
    Usually abstract classes would use abstract functions for the template method pattern (Gang of Four).
  • 1
    @azous assuming this is Java we can actually have working default methods in plain interfaces. Abstract classes, however, have the benefits of inheriting public and protected instance variables as well as having the behavior of an interface.
  • 1
    @luminous-flux yeah, i just didn't want to confuse him with this java 8 feature 😜
  • 0
    *bookmarks for exams*
Add Comment