码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-06-22 17:40:37      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:interface   bubuko   initial   clu   hit   inter   面向对象编程   init   override   

     第三章第四节 面向对象编程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 子类型多态、包含多态):

技术分享图片

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

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

标签:interface   bubuko   initial   clu   hit   inter   面向对象编程   init   override   

原文地址:https://www.cnblogs.com/masteryellow/p/9214290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!