java abstract classes and interfaces

Difference between abstract class and interface:

1: Abstract classes can only be inherited, and only single inheritance. Interfaces need to be implemented, and there can be multiple implementations.

2: Non-abstract methods can be defined in abstract classes, and subclasses can directly inherit and use them. There are abstract methods in the interface, which need to be implemented by subclasses.

3: The abstract class uses the is a relationship. The like a relationship used by the interface.

4: Member modifiers of abstract classes can be customized. Member modifiers in interfaces are fixed. All are public.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521907&siteId=291194637