An abstract class is a template definition of methods and variables of a class (category of objects) that contains one or more abstracted methods. Abstract classes are used in all object-oriented programming (OOP) languages, including Java (see Java abstract class), C++, C# and VB.NET. Objects or classes may be abstracted, which means that they are summarized into characteristics that are relevant to the current program’s operation.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Individual instances resulting from classes are objects. Declaring a class as abstract means that it cannot be directly instantiated, which means that an object cannot be created from it. That protects the code from being used incorrectly. Abstract classes require subclasses to further define attributes necessary for individual instantiation. Abstract classes contrast with concrete classes, which are the default type. A concrete class has no abstracted methods and can be instantiated and used in code.
Abstract classes aren’t required in programming but the concept is provided to keep code cleaner than it would be otherwise and make programming more efficient because extraneous details are not constantly being referred to. To be platform-agnostic, Java code is compiled into class files that can be interpreted by any Java VM. The resulting class file can run on different machines once a compatible Java VM has been downloaded and installed for the OS platform.
See a brief tutorial on abstract and concrete classes: