教材学习内容总结
第二章主要讲了 java 中基本数据类型和其转换, 如何使用表达式, 以及读入用户输入的方法
第三章主要是更详细地讲各种类的概念及使用, 使用类与对象来进行各种复杂操作, 还有枚举类型的概念
教材学习中的问题和解决过程
问题 1: 不知道如何提取字符串的单个字母.
问题 1 解决方案: 使用 char.charAt()命令.
问题 2:π如何表达?
问题 2 解决方案: 调用 Math 类中 Math.PI 即可
...
代码调试中的问题和解决过程
问题 1: 输出代码有问题.
问题 1 解决方案: 圆括号里面不能有 "," 必须用 + 把字符串和数值操作数连接起来.
问题 2: 执行提取部分字符串命令时错误.
问题 2 解决方案: 命令 String substring(int num1,int num2)错误, 应为 String.substring(int num1,int num2).
问题 3: 执行平方计算错误.
问题 3 解决方法: 命令输错, 应为 Math.pow(r,2)
问题 4: 显示非法表达式
问题 4 解决方法: 应将常数放在计算开头.
代码托管 https://gitee.com/zhang_jinghao/godzilla.git
上周考试错题总结
1, 错题: 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
解析:"实例化" 意味着创建对象的新实例, 这是基本知识点.
2, 错题: 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
解析: 如果两个字符串相同, compareTo 将生成 0,-1 如果第一个字符串在第二个字符串之前按字典顺序出现, 则生成 + 1, 如果第一个字符串在第二个字符串之后按字典顺序出现.
3, 错题: These two ways of setting up a String yield identical results:
- a) String string = new String(12345);
- b) String string = new String("12345");
- A .true
- B .false
解析: 没有接受数值参数的字符串构造函数的重载版本.
4, 错题: Consider the following statement:
- System.out.println("1 big bad wolf\t8 the 3 little pigs\n4 dinner\r2night");
- This statement will output ________ lines of text (思考下面的语句, 该语句将输出___行文本)
- A .1
- B .2
- C .3
- D .4
- E .5
解析: 转义序列插入制表符, 但将光标留在同一行. 转义序列会产生新行, 以便在下一行输出 "4 dinner". 转义序列导致回车(即, 光标移回左边距), 但由于它没有开始一个新行,"2night" 在 "4dinn" 上输出, 导致第二行看起来像 "2night".
5, 错题: If you want to output the text "hi there", including the quote marks, which of the following could do that? (如果你想输出文本 "hi there", 包括引号在内, 下面哪个语句可以做到?)
- A .System.out.println("hi there");
- B .System.out.println(""hi there"");
- C .System.out.println(""hi there");
- D .System.out.println(""hi there"");
- E .none, it is not possible to output a quote mark because it is used to mark the beginning and ending of the String to be output (无, 不可能输出引号, 因为它被用来标记字符串的开始和结束)
解析:" 是一个转义序列, 用于在字符串中放置引号, 因此这里使用它来输出引号和字符串的其余部分.
6, 错题: A cast is required in which of the following situations?
- A .using charAt to take an element of a String and store it in a char
- B .storing an int in a float
- C .storing a float in a double
- D .storing a float in an int
- E .all of the above require casts
解析: 对于 a,charat 返回一个 char, 因此没有问题. 在 b 和 c 中, 情况是扩大操作, 采用较窄的类型, 并将值存储在较宽的类型中. 只有在 d 中, 才会出现更宽类型存储在更窄类型中的情况, 因此需要强制转换.
7, 错题: If x is an int and y is a float, all of the following are legal except which assignment statement? (如果 x 是一个 int 类型的数, y 是一个 float 类型的数, 下面所有赋值语句中哪个不合法?)
- A .y = x;
- B .x = y;
- C .y = (float) x;
- D .x = (int) y;
- E .all of the above are legal (以上全部合法)
解析: 由于 X 是 int, 除非浮点是 int 型的, 否则它不能除浮点. B 中的赋值语句中没有明确的抛出. 在 A 中, 不需要一个抛出, 因为浮点 (y) 可以接受 int 值(x), 而在 c 和 d 中, 显式抛出使它们合法.
- 8,In order to create a constant, you would use which of the following Java reserved words? (为了创建一个常量, 你会使用下列 Java 保留字中的哪一个?)
- A .private
- B .static
- C .int
- D .final
- E .class
解析: 保留字 final 表示这是将存储在此变量中的最终值, 因此使其不可更改或为常量. 常量可以是 int 类型, 常量也可以是任何其他类型. 它是最后一个保留字, 使值不可更改.
9, 错题: Java is a strongly typed language. What is meant by "strongly typed"?
- A .Every variable must have an associated type before you can use it
- B .Variables can be used without declaring their type
- C .Every variable has a single type associated with it throughout its existence in the program, and the variable can only store values of that type
- D .Variables are allowed to change type during their existence in the program as long as the value it currently stores is of the type it is currently declared to be
- E .Variables are allowed to change types during their existence in the program but only if the change is to a narrower type
解析: 强类型是一种编程语言的属性, 通过它, 变量的类型在变量存在期间不会改变, 并且存储在该变量中的任何值都是该类型的. 强类型是重要的原因是它保证了成功编译的程序不会有与声明变量的类型的滥用相关联的运行时错误.
10, 错题: The values of (double) 5 / 2 and (double) (5 / 2) are identical. ((double) 5 / 2 和 (double) (5 / 2) 的值是相同的.)
A .true
B .false
解析: 在第一个表达式中,(double)强制转换应用于 int 5, 将其更改为 double 值 5.0. 然后计算 5.0/2, 得到双倍值 2.5. 在第二个表达式中, 首先执行 int 除法, 得到值 2. 然后将 2 更改为 double, 得到 double 值 2.0.
11, 错题: Every Interator
- A .has a hasNext( ) method
- B .has a hasFirst( ) method
- C .has a hasNextInt( ) method
- D .has a isEmpty( ) method
- E .none of the above
解析: 每个迭代器都有一个 hasNext()方法, 如果有迭代元素尚未处理, 则该方法为 true. 每个迭代器也有一个 next()方法, 该方法传递下一个元素以进行处理.
12, 错题: In order to compare int, float and double variables, you can use <,>, ==, !=, <=,>=, but to compare char and String variables, you must use compareTo( ), equals( ) and equalsIgnoreCase( ).
A .true
B .false
解析: 你也可以直接比较 char 变量, 使用 <,>,=,!=,<=,>=, 但必须使用 compareTo(),equals() 和 equalSignoreCase()进行任何字符串比较.
结对及互评
评分标准
基于评分标准, 我给本博客打分: 14 分. 得分情况如下:
正确使用 Markdown 语法(加 1 分):
模板中的要素齐全(加 1 分)
教材学习中的问题和解决过程, 加 4 分
代码调试中的问题和解决过程, 加 4 分
其他加分(加 4 分)
点评模板:
博客中值得学习的或问题:
内容详实且精简
问题充分且已解决
有配图
代码中值得学习的或问题:
正确且简练
方法多样很值得学习
...
参考示例
点评过的同学博客和代码
本周结对学习情况
其他(感悟, 思考等, 可选)
1, 这两周学的内容比较多, 有点跟不上, 但是多抽出点空闲时间还是能够学到更多东西的, 第四周, 我尽量抽出更多的时间去敲代码.
2, 尽量多看课本, 课本上的内容很详实, 有不会的先看课本, 再从网上搜.
学习进度条
代码行数(新增 / 累积) | 博客量(新增 / 累积) | 学习时间(新增 / 累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000 行 | 30 篇 | 400 小时 | |
第一周 | 200/200 | 2/2 | 20/20 | |
第二周 | 300/500 | 2/4 | 18/38 | |
第三周 | 500/1000 | 3/7 | 22/60 | |
第四周 | 300/1300 | 2/9 | 30/90 |
参考: 软件工程软件的估计为什么这么难, 软件工程 估计方法
计划学习时间: 30 小时
实际学习时间: 25 小时
参考资料
《Java 程序设计与数据结构教程(第二版)》 https://book.douban.com/subject/26851579/
《Java 程序设计与数据结构教程(第二版)》学习指导 https://www.cnblogs.com/rocedu/p/5182332.html
- ...
来源: http://www.bubuko.com/infodetail-3209091.html