1.1、抽象过程
万物皆为对象
1.2 、每个对象都有一个接口
1.3、每个对象都提供服务
1.4、被隐藏的具体实现
1)、访问权限控制原因之一就是让客户端程序员无法触及她们不该触及的地方
2)、第二个原因就是允许库设计者可以改变类内部的工作方式而不用担心会影响到客户端程序员
1.5、复用具体实现
组合和继承。组合更灵活。
1.6、继承
子类继承父类所有成员(private成员被隐藏起来了,并且不可访问),编程思想这么说。
注:是否继承是个“概念”问题,概念定义不同,当然结论不同。所以很多争论是鸡同鸭讲。
按java的标准,java语言规范http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.2:
Members of a class that are declared private are not inherited by subclasses of that class.
Only members of a class that are declared protected or public are inherited by subclasses declared in a package other than the one in which t he class is declared.
Constructors, static initializers, and instance initializers are not members and therefore are not inherited.
所以结论很明显了。
很多人理解的继承和java语言规范中所谓的“继承”不一样。所以结论也不一样。比如有人认为只要子类对象内存中有,就算继承(举个例子,父类 中定义了private int a; 子类对象中当然会分配相应的空间,所以有人以此为证据说,private的也被“继承”了)。
基类和导出类产生差异
1)、直接添加新方法。像一个
2)、改变现有基类方法(覆盖)。是一个,替代原则
1.7、伴随多态的可互换对象
后期绑定,默认行为。