Why do we need abstract classes in Java?

Why do we need abstract classes in Java? If you will never be an object, why do you do it? How do you use it? Why is there? I want to know the same thing as abstract methods I found that it seems to be a similar concept. There is a super class and no subclass, which may not matter

Solution

Abstract classes can be used as template types for other classes An abstract class will preserve common functionality for all classes that extend it

For example:

Abstract Class Animal

All animals move, breathe and reproduce, which can be put into animals

Now?

Concrete Class Dog,Cat etc.

These basic functions have been provided

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>