thinking in java(VI)--polymorphism

实现动态绑定的所需机制

1.      在执行期判知对象型别

2.      调用其相应的函数

 

 

Java中的函数除了有final修饰的,均采用了动态绑定

 

当然,构造函数是个例外,它没有多态性格

一个包含有继承和组合的复杂对象,其形成过程是这样的


一、分配所需heap空间并进行自动初始化,全部置为二进制零

二、循环调用当前类直接父类的构造函数

        直到当前类的父类是Object

        进行当前类成员的显式初始化,执行当前类的构造函数,回到其直接子类

        如此循环往复,直至回到最后一个子类


注:子类不能对父类成员进行显示初始化



《Thinking in Java》是由Bruce Eckel撰写的一本Java编程的经典教材,该书以英文语言出版。以下是该书的目录大纲: Chapter 1: Introduction to Objects - Introduction - The progress of abstraction - How objects communicate - Every object has an interface - The process of object-oriented design - Implementation hiding - Inheritance and reuse - Polymorphism and dynamic binding - Summary of object-oriented principles Chapter 2: Everything Is an Object - Primitive types - How the objects are created - Aliasing: All arguments are passed by value - Documentation comments - Controlling access to members of a class - First exposure to Java syntax Chapter 3: Operators - Thinking recursively - Operator precedence - Assignment with objects - Mathematical operators and precedence - Autoboxing and unboxing - Increment and decrement - Java logic operators - Bitwise operators - The instanceof operator - Summary of operators Chapter 4: Control Structures: Part 1 - True and false - The if-else statement - The switch statement - The while statement - The do-while statement - The for statement - Summary of control structures Chapter 5: Control Structures: Part 2 - The break and continue keywords - Foreach and multidimensional arrays - Using the comma operator - The return keyword - Summary of control structures Chapter 6: Initialization & Cleanup - Member initialization - Constructor initialization - Method overloading & generic methods - Order of initialization - Constructor & parameter lists - Garbage collection - The finalize() method - Summary of initialization and cleanup ......(接下去的章节继续)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值