What is an abstract class?
The method modified by abstract
is called an abstract method; the class modified by abstract
is called an abstract class.
An abstract class cannot be instantiated because it is not a concrete class, or such a class is not complete enough and cannot directly use the new keyword to call its constructor to generate an object of this class. We can use abstract to define an abstract class and abstract method.
Abstract class instance:
abstract class 类名 { abstract int 方法名(int x,int y); }
Abstract methods have no method body. It should be noted that abstract classes can have both abstract methods and ordinary methods. Note that abstract methods do not have method bodies (that is, there are no curly braces after the methods). All entity subclasses that inherit this abstract class must implement this abstract method.
Characteristics of abstract classes:
(1) Abstract classes cannot be instantiated
(2) Constructors and static methods cannot be abstract
(3) Abstract methods of parent classes are often implemented in subclasses
(4) Abstract classes can have object references pointing to subclass objects
Recommended tutorials:java tutorial
The above is the detailed content of How to understand abstract classes in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)