20162308 2016-2017-2 《程序设计与数据结构》第8周学习总结
教材学习内容总结
- 熟悉异常继承体系
- 掌握异常处理
- 理解方法覆盖和动态绑定
- 会用UML建模工具
- 熟悉Java IO API
教材学习中的问题和解决过程
- throw & throws
- thorw: 抛出异常具体的动作,throws:声明需要调用方法的上一级语句需要处理的异常。
public void dothing(int a,int b) throws Exception1,Exception3 {
try{
//......
}catch(Exception1 e){
throw e;
}catch(Exception2 e){
//方法内处理异常
System.out.println("自行处理");
}
if(a!=b)
//交由上一级语句处理
throw new Exception3();
}
- 动态绑定 & 静态绑定
- 阅读资料
Java静态绑定与动态绑定
JAVA动态绑定的内部实现机制 - Java中父类的属性在子类中是静态绑定的,而方法则是动态绑定的,所以父类的方法在子类中重写后,调用的就是重写后的代码。
代码调试中的问题和解决过程
- 在完成PP10.7时,使用set集合进行去重操作,编译时出现警告。
- 查阅资料后,有两个解决方案
- 方法一:在Library前加上@SuppressWarnings("unchecked")就可以解决。
- 方法二:在声明set时指定泛型。
Set<String> s = new HashSet<String>();
代码托管
- 代码提交过程 & 代码量截图:
上周考试错题总结
- The commitment to execute certain code to carry out a method invocation is referred to as _____________(通过提交来执行确定的代码从而完成方法的调用,被称为).
A .execution(执行)
B .binding(绑定)
C .polymorphism(多态)
D .inheritance(继承)
E .none of the above(以上都不正确)
答案:B,Binding refers to the commitment to execute certain code to carry out a method invocation. - Which of the following methods are included with any object that implements the Iterator interface? (下面哪个方法包含了实现Iterator接口的对象?)
A .next
B .hasNext
C .toString
D .all of the above(以上都正确)
E .a and b(a和b)
答案:D,做这题的时候光想着Iterator了,忘记了每一个类都是Object的子类,而Object中已经定义了toString方法。 - Suppose Animal is an interface that specifies a single method – speak. Now suppose the Dog class implements the Animal interface. In addition to the speak method, the Dog class also has a method called wagTail. Now consider the following code(假设Animal是一个指定了单一方法的接口--speak。现在假设Dog类实现了Animal接口。除了speak方法外,Dog类还有一个方法wagTail。现在思考下面的代码:).
Animal a = new Dog();
a.wagTail();
Which of the following is true about this code?(关于这段代码,下面哪项是正确的)
A .It will result in a compile-time error(这段代码会引起编译时错误).
B .It will result in a run-time error.(这段代码会引起运行时错误)
C .It will call the speak method defined in the Animal interface. (这段代码将会调用Animal接口中的speak方法)
D .It will call the wagTail method defined in the Dog class(这段代码将会调用Dog类中的wagTail方法).
E .none of the above are true. (以上都正确)
答案:D,这个是动态绑定相关的问题,上周对相关的知识点还是太生疏。
结对及互评
张师瑜的博客笔记记得很认真,要多敲代码,多写博客,做中学。
其他(感悟、思考等,可选)
- 这周已经完全看懂K-means算法了,然后就感觉,这个算法有很大的缺陷,应用在我的项目中虽然能凑合着用,但是不那么完美。所以,又开始投奔神经网络算法。学习ANN是一个很痛苦的过程,因为始终都不知道为什么要这么做。陡峭的学习曲线下,得到正反馈的时间很长,至少我现在对于ANN还有很大的疑惑,包括层数的选择,节点的选择,等等方面,都存在很大的问题。但是不管怎么说,既然是问题,那就是用来被解决的,相信自己的智商,相信自己能够在接下来的一周能够做出一份很棒的答辩PPT。
学习进度条
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 | |
第一周 | 26/26 | 1/1 | 7/7 | |
第二周 | 81/107 | 1/2 | 8/15 | String类型的使用 |
第三周 | 80/187 | 1/3 | 5/20 | 位运算 |
第四周 | 300/487 | 1/4 | 8/28 | 动态数组和迭代器 |
第五周 | 132/619 | 1/5 | 18/46 | OOP编程导论 |
第六周 | 90/709 | 1/6 | 5/51 | 多线程 |
第七周 | 596/1305 | 1/7 | 20/71 | K-Means |
第八周 | 55/1360 | 1/8 | 8/79 | ANN & DL |
-
计划学习时间:8小时
-
实际学习时间:20小时