学号 2019-2020-1 《数据结构与面向对象程序设计》第2&3周学习总结
教材学习内容总结
- 利用Scanner来完成输入,了解各种数值的输入和单个字符的输入方法。
- 学会编写简单的计算器,完成加减乘除模运算。
- 类的定义和使用。
- 方法的定义和调用及其重载。
- String 的用法。
random和DecimalFormat的用法
教材学习中的问题和解决过程
- 问题1:赋值时对于float的赋值方法不理解。
- 问题1解决方案:java中赋float值的时候要在后面加上f如 float a= 10.0f;否则就会丢失精度。
- 问题2:不明白long的使用方法。
- 问题2解决方案:如果z=9999999999,超出了int的取值范围,那么就必须在命名的时候在数字后面加上L如:long z= 9999999999L。
代码调试中的问题和解决过程
问题1:代码名字里面不能设置为PP2.2。

问题1解决方案:把2.2改成2_2。

问题2:PP3_1运行的时候显示有问题。

问题2解决方案:名字不能少于5个字母。


上周考试错题总结
- If two variables contain aliases of the same object then
- A .the object may be modified using either alias
- B .the object cannot be modified unless there‘s but a single reference to it
- C .a third alias is created if/when the object is modified
- D .the object will become an "orphan" if both variables are set to null
- E .answers A and D are correct
- 正确答案: E 我的答案: C
- 解析:如果两个变量都被设置为null,那么这个对象就不会被任何变量引用
- In Java, "instantiation" means
- A .noticing the first time something is used
- B .creating a new object of the class
- C .creating a new alias to an existing object
- D .launching a method
- E .none of the above
- 正确答案: B 我的答案: E
- 解析:instantiation意味着为类创建一个新文件。
- Say you write a program that makes use of the Random class, but you fail to include an import statement for java.util.Random (or java.util.*). What will happen when you attempt to compile and run your program.
- A .The program won‘t run, but it will compile with a warning about the missing class.
- B .The program won‘t compile-you‘ll receive a syntax error about the missing class.
- C .The program will compile, but you‘ll receive a warning about the missing class.
- D .The program will encounter a runtime error when it attempts to access any member of the Random class
- E .none of the above
- 正确答案: B 你的答案: E
- 解析:不把package导入就直接引用会报错。
- Consider the following two lines of code. What can you say about s1 and s2?
String s1 = "testing" + "123";
String s2 = new String("testing 123");
- A .s1 and s2 are both references to the same String object
- B .the line declaring s2 is legal Java; the line declaring s1 will produce a syntax error
- C .s1 and s2 are both references to different String objects
- D .s1 and s2 will compare "equal"
- E .none of the above
- 正确答案: C 你的答案: D
- 解析:这里string的应用跟print的类似。
- The String class‘ compareTo method
- A .compares two string in a case-independent manner
- B .yields true or false
- C .yields 0 if the two strings are identical
- D .returns 1 if the first string comes lexically before the second string
- E .none of the above
- 正确答案: C 你的答案: E
- 解析:compareTo是比较的作用比较函数,用法是A.compareTo(B)
- 如果A>B,返回值为1
如果A=B,返回值为0
如果A<B,返回值为-1
一般用在if()里面
- The advantages of the DecimalFormat class compared with the NumberFormat class include
A .precise control over the number of digits to be displayed
B .control over the presence of a leading zero
C .the ability to truncate values rather than to round them
D .the ability to display a % automatically at the beginning of the display
E .only A and B
- 正确答案: E 我的答案: C
- 解析:NumberFormat和DecimalFormat都是它的子类关于数字的。DateFormat和SimpleDateFormat也是它的子类关于文字的。
- These two ways of setting up a string yield identical results:
a) String string = new String("string");
b) String string = "string";
A .true
B .false
正确答案: A 你的答案: B
解析:上面两者都行,类似于c语言中数组的命名
- These two ways of setting up a String yield identical results:
a) String string = new String("123.45");
b) String string = "" + 123.45;
A .true
B .false
正确答案: A 你的答案: B
解析:这里string的用法与print类似
结对及互评
- 基于评分标准,我给本博客打分:12分。得分情况如下:
- 正确使用Markdown语法(加1分):
- 不使用Markdown不加分
- 有语法错误的不加分(链接打不开,表格不对,列表不正确...)
- 排版混乱的不加分
- 模板中的要素齐全(加1分)
- 缺少“教材学习中的问题和解决过程”的不加分
- 缺少“代码调试中的问题和解决过程”的不加分
- 代码托管不能打开的不加分
- 缺少“结对及互评”的不能打开的不加分
- 缺少“上周考试错题总结”的不能加分
- 缺少“进度条”的不能加分
- 缺少“参考资料”的不能加分
教材学习中的问题和解决过程, 一个问题加1分
代码调试中的问题和解决过程, 一个问题加1分
5.感想,体会不假大空的加1分
7.进度条中记录学习时间与改进情况的加1分
有动手写新代码的加1分
点评认真,能指出博客和代码中的问题的加1分
结对学习情况真实可信的加1分
错题学习深入的加1分
点评过的同学博客和代码
其他(感悟、思考等,可选)
java的方法引用和c语言的函数调用有异曲同工之妙,而且在程序的编写上面也有许多共通之处,但也不能太过依赖c语言总结的经验,比如单个字符的输入就有很大的区别。以后的学习中一定要更加细心的对待每一道题,争取能够学好这门语言。
学习进度条
目标 |
5000行 |
30篇 |
400小时 |
|
第一周 |
126/126 |
2/2 |
20/20 |
|
第二周&第三周 |
353/479 |
3/5 |
20/40 |
|
学号 2019-2020-1 《数据结构与面向对象程序设计》第2&3周学习总结
原文:https://www.cnblogs.com/pytznb/p/11570042.html