search
HomeJavaJavagetting StartedWhat is the connection between abstract classes and interfaces?

What is the connection between abstract classes and interfaces?

Aug 03, 2020 pm 04:37 PM
abstract classinterface

What is the connection between abstract classes and interfaces?

Contact:

(Recommended tutorial: java introductory tutorial)

1. Anyone can have abstract methods

2. Neither can directly create objects.

3. They all rely on the existence of subclasses to make sense. Subclasses must implement all their abstract methods.

4. All can implement multiple State

Difference:

Different members:

There is no constructor method in the interface, while abstract classes have constructor methods but cannot directly create objects.

Member methods in the interface are modified by public abstract by default, and only abstract methods can exist. There are both abstract methods and ordinary methods in abstract classes.

Member variables in the interface are decorated with static final by default, and only static constants are public. Variables in abstract classes do not have this restriction.

(Video tutorial recommendation: java video tutorial)

Different relationships:

The relationship between classes is inheritance: extends.

The relationship between interfaces is inheritance: extends.

The relationship between classes and interfaces is implementation: implements. Subclasses are called subimplementation classes.

The above is the detailed content of What is the connection between abstract classes and interfaces?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools