Graphical demonstration of abstract classes and interfaces in java
First look at the picture:
Abstract method: A method without a method body must be modified by abstract in an abstract class Methods.
1. Abstract classes can have abstract methods and ordinary methods
2.Abstract classes cannot be instantiated
3.Abstract methods must be overridden
4. Use of abstract classes:
1) Concrete subclasses: Rewrite all abstract methods and add new ones as needed
2) Abstract subclasses: Rewrite as needed and add new ones as needed Add
5. Once an abstract method is overridden, it can no longer be rewritten
6.Abstract cannot be used together with static, private, final, and native
Free learning video recommendations : java online tutorial
Note:
1. The use of abstract methods must be rewritten
2. The interface cannot be instantiated
3. An implementation class is required to implement the interface, use the content in the interface
Concrete implementation class: All abstract methods must be rewritten as needed Added
abstract implementation class: Rewrite as needed Add new
abstract implementation class as needed. The use of abstract implementation class requires subclasses to inherit the abstract class and rewrite all abstract methods.
4. Class inheritance uses the extends keyword, and implementation uses the implements keyword
5. A class can implement multiple interfaces, such as: class Test implements Demo,A,B
6. A class should be inherited first and then implemented.
7. A class can only implement a few interfaces and inherit from the parent class, but interfaces can only inherit multiple interfaces.
8. Single inheritance between classes
Recommended related articles and tutorials: zero basic introduction to java
The above is the detailed content of Graphical demonstration of abstract classes and interfaces 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

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.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
