1, classes and relations: the extends Inheritance / single inheritance / single inheritance
-- 继承的意义:为了提高代码的复用性,减少了代码的编写提高开发效率。
-- 方法重写的意义:在不修改父类源码的前提下,在子类中重写业务,从此使用的就是重写后的功能。
-- 要求子类的方法声明和父类一样,只要改方法体。
-- 有了继承有了重写就产生了多态,多态的意义:为了统一程序的调用标准,标准就是父类。
-- 多态 也就是向上转型/向上造型。
-- 向下造型的意义:很少用,相当于想要使用子类的特殊功能,还不如直接创建子类对象简单。
-- class A extends B
-- 其中,A和B都是类,A是子类,B是父类,A就拥有了B的所有功能(除了私有的和构造方法)
-- 其他知识点:this 和super ,构造方法,各种代码块...
2, the relationship between classes and interfaces: the implements realize / implement Single / Multi implemented
-- class A implements B,C
-- 其中,A是实现类,B和C是接口
-- 要求A 可以把 B 和C 接口里的所有 抽象方法 都重写掉,否则 A 就是抽象类
-- 接口不能创建对象
-- 接口里没有构造方法,接口里都是常量,接口里都是抽象方法
3, interface and its relationship: inheritance extends / single inheritance / multiple inheritance
-- 接口的多继承的关系,打破了java单继承的局限性
-- interface A extends B,C
-- 其中,A B C 都是接口,A是子接口,同时拥有B和C接口里的所有功能
-- class AImpl implements A
-- 要求AImpl需要重写A接口里的所有方法(是包含B和C接口的所有方法),否则就是抽象类
4, the difference between interfaces and abstract classes! ! !