软件构造 第三章第四节 面向对象编程OOP

     第三章第四节 面向对象编程OOP

Interface: specifies expectations 接口:确定ADT规约

Class: delivers on expectations (the implementation) 类:实现ADT

 

继承extends

严格继承 :子类只能添加新方法,无法重写超类中的方法,加final

 

Final:

A final field: prevents reassignment to the field after initialization

A final method: prevents overriding the method

A final class: prevents extending the class

 

Override:

    重写的函数:完全同样的signature

实际执行时调用哪个方法,运行时决定。

 

多态:

1.Ad hoc polymorphism ( 特殊多态) 参数类型不同,overload(编译时确定,参数必须不同)

2.Parametric polymorphism ( 参数化多态) 泛型

3.Subtyping (also called subtype polymorphism or inclusion polymorphism 子类型多态、包含多态):

子类型多态:不同类型的对象可以统一的处理而无需区分

猜你喜欢

转载自www.cnblogs.com/masteryellow/p/9214290.html