O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required