20172332 2017-2018-2 《程序设计与数据结构》第八周学习总结
教材学习内容总结
第十章多态性
- 1.后绑定。
- 2.利用继承实现多态性。
- 3.利用接口实现多态性。
- 4.排序。
- 选择法排序。(从左到右扫描到最小的数)
- 插入法排序。(依次选取数与之前排列好的数列进行比较然后插入)
- 综合考虑,选择法优于插入法。
- 5.搜索。
- 线性搜索。
- 二分搜索。(必须是按顺序排列好的)
- 二分搜索的效率高于线性搜索,但是线性搜索的实现比二分搜索简单。
- 6.多态性设计(多个不同对象执行相同的基本行为,并且行为的不同实现方式取决于对象的具体类型。)
教材学习中的问题和解决过程
- 问题1:二分搜索时若数组元素个数为双数怎么取中间值?
- 问题1解决方案:选中间两值相加除以2,然后取整为中间值,进行比较。
- 问题2:这种实例化语句,如Speaker current = new Philosopher();,怎么理解?
- 问题2解决方案:这就与多态性有关,可以理解为定义一个实现Speaker接口的类Philosopher,就可以将Philosopher对象(就是current)赋给Speaker接口引用变量。
代码调试中的问题和解决过程

上周考试错题总结
1.Abstract methods are used when defining
- A . interface classes
- B . derived classes
- C . classes that have no constructor
- D . arrays
- E . classes that have no methods
- 答案:A ;我选的:E
- 分析:接口中全是抽象方法。
- 单词:1.derived:继承。
2.A variable declared to be of one class can later reference an extended class of that class. This variable is known as
- A . protected
- B . derivable
- C . cloneable
- D . polymorphic
- E . none of the above, a variable declared to be of one class can never reference any other type of class, even an extended class
- 答案:D ;我选的:A
- 分析:此题与多态性有关,当时还没学,现在学完了多态,很容易理解。(简单理解就是,A类型的变量可以用B类型的方法。)
- 单词:1.polymorphic:多态。
3.In order to determine the type that a polymorphic variable refers to, the decision is made
- A . by the programmer at the time the program is written
- B . by the compiler at compile time
- C . by the operating system when the program is loaded into memory
- D . by the Java run-time environment at run time
- E . by the user at run time
- 答案:D ;我选的:A
- 分析:多态变量可以采取许多不同的类型,但不知道它在执行程序之前采取了什么类型。在引用变量时,必须做出决定。这个决定是由运行时环境基于变量的最新赋值来实现的。
- 单词:1.compiler:编译程序。
点评过的同学博客和代码
其他(感悟、思考等,可选)
- 本周内容中的排序和搜索,在学数组时的视频中有提及,所以不是很难理解。至于有关多态方面的知识,可能会用, 但是还不是很能理解。
学习进度条
目标 |
5000行 |
30篇 |
400小时 |
|
第一周 |
182/182 |
1/1 |
10/10 |
|
第二周 |
458/640 |
1/2 |
15/25 |
|
第三周 |
469/1109 |
2/4 |
18/43 |
学会IDEA的使用和调试,学会jdb调试。 |
第四周 |
1536/2645 |
1/5 |
24/67 |
|
第五周 |
980/3625 |
1/6 |
25/92 |
|
第六周 |
870/4495 |
1/7 |
16/108 |
|
第七周 |
455/4950 |
2/9 |
22/130 |
|
第八周 |
1322/6272 |
2/11 |
28/158 |
|
参考资料
20172332 2017-2018-2 《程序设计与数据结构》第八周学习总结
原文:https://www.cnblogs.com/yu757503836/p/8915516.html