CHAPTER 18

image

Abstract

An abstract class provides a partial implementation that other classes can build upon. When a class is declared as abstract it means that the class can contain incomplete methods that must be implemented in subclasses, in addition to normal class members. These methods are left unimplemented and only specify their signatures, while their bodies are replaced by semicolons.

abstract class Shape{   public int x = 100, y = 100;  public abstract int getArea();}  

Abstract class example

If a class called Rectangle inherits from the abstract class Shape, Rectangle is then forced to override the abstract getArea method. The only ...

Get Java Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.