Where and what is the abstract modifier used for

A class marked with the abstract modifier is called an abstract class. Such classes can only act as ancestors for other classes. The abstract class itself is not allowed to be instantiated. In this case, both other abstract classes and classes that allow the creation of objects can be heirs of an abstract class.

A method marked with the abstract keyword is an abstract method, i.e. a method that has no implementation. If there is at least one abstract method in the class, then the whole class must be declared abstract.

Using abstract classes and methods allows you to describe a certain object template that must be implemented in other classes. They themselves describe only a certain behavior common to all descendants.


Read also:


Comments

Popular posts from this blog

Methods for reading XML in Java

XML, well-formed XML and valid XML

ArrayList and LinkedList in Java, memory usage and speed