Abstract Class

 The keyword abstract is used to make a class abstract.

an abstract class can contain constructors in Java. And a constructor of abstract class is called when an instance of a inherited class is created. Moreover it can also have final methods in the abstract class.

Remember , it’s uptown you if you want to add abstract methods or not .

You might be asking what is an abstract method anyways ?

method that is declared without an implementation (without braces and followed by a semicolon)

( all code will be available at the bottom of the page with a link to the program on my GitHub)

When should you want to use an abstract class ?

  1. You want to share code among several closely related classes.
  2. You expect that classes that extend your abstract class have many common methods or fields or require access modifiers other than public (such as protected and private).
  3. You want to declare non-static or non-final fields. This enables you to define methods that can access and modify the state of the object to which they belong.

Citation :

https://dzone.com/articles/when-to-use-abstract-class-and-intreface,

https://www.geeksforgeeks.org/abstract-classes-in-java/

Githutb : https://github.com/ValorWind1/Java_Review_1.0/tree/master/src/intermidiate_Java/abstract_Class

Leave a comment