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!

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

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

Hot Article

Hot Tools

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
Visual web development tools

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

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

WebStorm Mac version
Useful JavaScript development tools