move()
是一个方法,引用变量Animal creature = new Horse
指向Horse
后(Horse是Animal子类),creature.move()
就调用Horse
中的move()
方法。本周教材学习中无重大问题,老师和助教解答很详细。html
问题1:想要尝试一下继承实现多态,基本思路为Demo类中i = 4
,SuperDemo类中i = 7
,最后输出结果应该是SuperDemo类中的7
,结果倒是SuperDemo = 0
。
git
问题1解决方案:查找网上相似的问题,获得一点启发。执行new SuperDemo()
的时候先调用了父类的Demo()
,而该构造里边又引用了子类的show
方法,但那时候子类构造还未执行,i
变量仅仅被分配了内存并赋予默认的0
,因此打印的是0
。应该是这样。编程
(statistics.sh脚本的运行结果截图)数据结构
错题1: Which of the following is true regarding Java classes?
正确答案:A .All classes must have 1 parent but may have any number of children (derived or extended) classes
缘由:每个类都直接或者间接的是Object类的子类。函数
错题2:A variable declared to be of one class can later reference an extended class of that class. This variable is known as
正确答案:D .polymorphic
缘由:没有很好的理解题目意思,觉得是“一个类中的变量能够被本身的子类引用”之类的,从而误选为protected。学习
错题3:In order to determine the type that a polymorphic variable refers to, the decision is made
正确答案:D .by the Java run-time environment at run time
缘由:多态性引用的类型判断是在程序运行时,也就是动态绑定。设计
错题4:Using the reserved word, super, one can
正确答案:E .none of the above
缘由:super保留字既能引用构造函数,也能引用方法和数据。调试
错题5:If class AParentClass has a protected instance data x, and AChildClass is a derived class of AParentClass, then AChildClass can access x but can not redefine x to be a different type.
正确答案:B .false
缘由:这是能够实现的,经过保留字super的使用。code
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 | |
第一周 | 195/195 | 1/4 | 20/20 | 对代码产生了很大兴趣 |
第二周 | 309/504 | 1/5 | 20/40 | 打字速度明显提高 |
第三周 | 311/815 | 2/7 | 25/65 | 无 |
第四周 | 474/1289 | 1/8 | 30/95 | 抗...抗压能力增强? |
第五周 | 260/1549 | 1/9 | 15/110 | 了解到预习的重要性 |
第六周 | 358/1907 | 2/11 | 20/130 | 打字速度明显提高 |
第七周 | 780/2687 | 2/13 | 15/145 | 学会使用JUnit |
第八周 | 2124/4811 | 2/10 | 15/160 | 无 |
20172319唐才铭htm