Home  >  Article  >  Java  >  Graphical demonstration of abstract classes and interfaces in java

Graphical demonstration of abstract classes and interfaces in java

王林
王林forward
2019-11-29 14:51:132594browse

Graphical demonstration of abstract classes and interfaces in java

First look at the picture:

Graphical demonstration of abstract classes and interfaces in java

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

Graphical demonstration of abstract classes and interfaces in java

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

Graphical demonstration of abstract classes and interfaces in java

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!

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