码迷,mamicode.com
首页 > 其他好文 > 详细

20172304 2017-2018-2《程序设计与数据结构》 第3周学习总结

时间:2018-03-25 12:04:05      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:0.00   产生   mat   string类   个数   htm   老师   oci   min   

学号 2017-2018-2 《程序设计与数据结构》第3周学习总结

教材学习内容总结

本周教材主要介绍了如下几个方面:
1.创建对象
2.Sring类
3.包
4.Random类
5.Math类
6.格式化输出
7.枚举型

教材学习中的问题和解决过程

  • 问题1:关于Random类的问题
  • 问题1解决方案:在进行随机变量的取值时出现了很多问题,比如数字的位数不确定等,后来上网上搜索发现配合if命令可以实现每个数字的随机取值。

  • 问题2:关于string类的一些应用不是很清楚。
  • 问题2解决方案:通过书上的例题,自己动手敲了几个例子和程序就懂了。

    比如书上的 >char chatAt(int index)在实际操作时需要用成文件名.charAt(数字);

代码调试中的问题和解决过程

  • 问题1:在进行代码编译时出现了问题
    技术分享图片

  • 问题1解决方案:后来进行排查时发现
  • scan = nextDouble;没有加括号

    代码托管

    技术分享图片

  • 问题2:在进行格式化输出的例子时发现自己敲得程序输出的是人民币。而书上的是美元。
  • 问题二解决方案:后来想到可能是自己选的位置是上海。

上周考试错题总结

错题一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
正确答案: B 你的答案: C
错题分析:其实我是知道/n是换行符/r是回车符的,但是不知道为什么还是选了c.

错题二What value will z have if we execute the following assignment statement? float z = 5 / 10; (如果我们执行下面的赋值语句,得到的z将会是什么值?)
A . z will equal 0.0 (z将等于0.0)
B . z will equal 0.5 (z将等于0.5)
C . z will equal 5.0 (z将等于5.0)
D . z will equal 0.05 (z将等于0.05)
E . none of the above, a run-time error arises because z is a float and 5 / 10 is an int (以上都不对,因为z是float类型,5 / 10是int类型,所以会发生运行时错误)
正确答案: A 你的答案: B
错题分析:这里,等式右边是一个整数型的除法,所以结果舍弃小数部分,得到0,进行扩展类型转换后就得到了0.0.

错题三Which of the following is true regarding the mod operator, %? (关于求余运算符%,下面哪项是正确的?)
A . It can only be performed on int values and its result is a double (它只能执行int类型的数值,其结果是double类型的数)
B . It can only be performed on int values and its result is an int (它只能执行int类型的数值,其结果也是int类型的数)
C . It can only be performed on float or double values and its result is an int (它只能执行float或者double类型的数值,其结果是int类型的数)
D . It can only be performed on float or double values and its result is a double (它只能执行float或者double类型的数值,其结果是double类型的数)
E . It can be performed on any numeric values, and the result always is numeric (它可以执行任何类型的数值,其结果始终是数值)
正确答案: E 你的答案: B
错题解析:有关于求余符号的适用范围,我并没有在书上找到准确的定义,后来自己经过实践才知道准确的用法。

错题四What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? (如果x和y是int类型的数值,x=10,y=5,那么语句System.out.println(x+y);的输出是什么?)
A . 15
B . 105
C . 10 5
D . x+y
E . An error since neither x nor y is a String (因x和y都不是字符串而引起的一个错误)
正确答案: A 你的答案: B
错题解析:这道题没什么好讲的,就是进行加法运算,然后输出结果。

public class test {
public static void main(String[] args) {
int x=10;
int y=5;
System.out.println(x+y);
}
}
output:15

错题五What is output with the statement System.out.println(""+x+y); if x and y are int values where x=10 and y=5? (如果x和y是int类型的数值,x=10,y=5,那么语句System.out.println(""+x+y);的输出是什么?)
A . 15
B . 105
C . 10 5
D . x+y
E . An error since neither x nor y is a String (因x和y都不是字符串而引起的一个错误)。
正确答案:B 你的答案:C
错题解析:
public class test {
public static void main(String[] args) {
int x=10;
int y=5;
System.out.println(""+x+y);
}
}
output:105

错题六If you want to store into the String name the value "George Bush", you would do which statement? (如果你想把"George Bush"这个值存储为字符串类型的名字,你会执行那条语句?)
A . String name = "George Bush";
B . String name = new String("George Bush");
C . String name = "George" + " " + "Bush";
D . String name = new String("George" + " " + "Bush");
E . Any of the above would work (上述都可以完成)
正确答案: E 你的答案: B
错题解析:这道题好像是下一章的内容,这是老师在考验我们的预习情况?

错题七What value will z have if we execute the following assignment statement?
int z = 50 / 10.00; (如果我们执行下面的赋值语句,z将得到什么值?)
A . 5
B . 5.0
C . 50
D . 10
E . none of the above, a run-time error arises because z is an int and 50 / 10.00 is not (以上皆错,因z是一个整型数而50 / 10.00不是,会产生运行时错误)
正确答案: E 你的答案: A
错题解析:这个我是知道的不知道为什么错了,因为在等号右边有一个浮点数10.00所以等号右边应该生成一个浮点数5.00,而等号左边是一个整数型,所以会产生错误的结果。

错题八Java is a strongly typed language. What is meant by "strongly typed"? (Java是一种强类型语言。“强类型”指的是什么?)
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 (变量存在于程序中时允许改变类型,但只能缩窄转换)
正确答案: C 你的答案: A
错题解析:这种定义题,记住就行了吧。

错题九The values of (double) 5 / 2 and (double) (5 / 2) are identical. ((double) 5 / 2和(double) (5 / 2)的值是相同的。)
A . true
B . false
正确答案: B 你的答案: A
错题解析:不,应该是不同的,在前一种定义方式中,是将五定义成了浮点型,所以最后输出的应该是浮点数2.5。而在后一种定义方式中,是先进行5/2的计算,得到2,然后再将其转化为浮点型2.0。2.5>2.0,所以答案很明显选A。

其他(感悟、思考等,可选)

 经过这周的学习,我更加地体会到学习代码的不容易,需要日耕不缀,而且越学习越会发现自己的无知。革命尚未成功,同志们仍需努力。

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 5000行 30篇 400小时
第一周 75 /200 1/2 20/20
第二周 338/413 1/2 18/38
第三周 515/928 1/3 22/60

参考资料

20172304 2017-2018-2《程序设计与数据结构》 第3周学习总结

标签:0.00   产生   mat   string类   个数   htm   老师   oci   min   

原文地址:https://www.cnblogs.com/15248252144dzx/p/8642025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!