Summary of JAVA basics, interfaces, and abstract relationships

The relationship between class and class:

1,类和类之间存在继承关系,且是单继承关系 如:class  A extends classB
2,   其中A是子类,B是父类
3,A子类可以无条件使用B父类中的非私有资源
4,A子类可以重写B父类中的方法,但是B父类中的方法不会被改变

The relationship between class and interface:

1,类可以实现接口,并且可以多实现 如: class A implements B,C,..
2,其中A是实现类,需要实现B和C中的所有方法,因为接口是一个特殊的抽象类,如果不实现那么A也必须是抽象的;
3,类可以调用接口中的静态常量,因为接口中的变量默认都是被 static final 所修饰的;

The relationship between interface and interface:

1,接口可以继承接口,并且是多继承关系 如:interface A extends B,C
2,其中A接口可以使用B,C接口中的所有资源(非私有),如有实现A接口的实现类,必须要同时实现A,B,C接口中的所有方法,否者该类为抽象类;
3,类可以先继承一个类,同时还可以实现多个接口,如class  A extends B,implements B,C
4,A类必须实现 B ,C接口中的所有方法,而无需重写 B类中的所有方法;
5,接口中的方法都是抽象方法(这里不太理解,如JDK1.8可以使用  default 修饰普通方法,或者用static Find()方法 )

Abstract class:
1. Abstract class refers to the class modified by abstract. It is a special class.
2. The abstract class can have ordinary methods, as well as ordinary variables and constants.
4. Abstract classes can have construction methods. , But cannot directly instantiate objects, but exists for subclasses to instantiate objects.
5, abstract classes cannot be directly instantiated

brothers! Did you lose school?

Guess you like

Origin blog.csdn.net/DoChengAoHan/article/details/107944709