20172325 2016-2017-2 《Java程序设计》第四周学习总结
20172325 2016-2017-2 《Java程序设计》第四周学习总结
教材学习内容总结
1.对类、对象、声明变量的定义和属性有了进一步的了解
2.学会如何编写一个类并运用到需要的程序中
3.学习了形参和实参的概念和区别
4.修饰符的作用和运用,例如public和private
5.学习了静态类,例如静态方法和静态变量
6.关于封装的作用和运用
7.在面向对象的程序设计时需要做的必要步骤,包括需求、设计、实现和测试
8.对枚举类的进一步了解
9.学习了调用方法中的方法重载
10.UML类图包含的内容和作用,有助于对类的理解
教材学习中的问题和解决过程
- 问题1:区分不了对象和类
问题1解决方案:首先是通过学习教材了解具体定义,然后百度具体区别,然后通过具体操作加深理解。下面是自己的理解,类是一个规则一个标准或者说一个模范,是一个虚拟的存在;对象是一个可变的的个体,有具体的需求和形态。而对象和类的联系在于对象的实现需要通过类来规范。
- 问题2:在形参和实参的理解和运用上很头疼
问题2解决方案:之前是在网上查询,可以参考这篇博客[(https://www.cnblogs.com/calence/p/5346672.html)]
后来老师在课上也给出了很详细的讲解。
代码调试中的问题和解决过程
- 问题1:对于getFaceValue和setFaceValue的作用不是很清楚,在敲例题4.2的时候,中间加了这两个方法和删除之后运行没有差别,不知道为何。
问题1解决方案:通过看书以后了解到,他们是同级的不同调用方法,内容不一样而已,这就是在设计时输入get和set先后顺序对于结果没有影响
问题2:如下图,不知道是什么情况,自从出现了这个东西,试了之前编译运行成功的程序也出现这样的结果。
代码托管
上周考试错题总结
1.In Java a variable may contain
A a value or a reference
B a package
C a method
D a class
E any of the above
在JAVA中变量只能包含一个值或一个引用。所以应该选a的。2.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
对象可以使用别名进行修改,如果两个变量都设置为null,那么对象将变成一个“孤儿”。3.Which properties are true of String objects?
A Their lengths never change
B The shortest string has zero length
C Individual characters within a String may be changed using the replace method
D The index of the first character in a string is one
E Only A and B are true
他们的长度永远不会改变,最短的字符串长度为零。字符串是不可变的。这意味着, 一旦创建了字符串对象, 就不能更改它。因此, 字符串的长度在创建后不会更改。最短长度字符串为 "", 引号之间没有字符, 因此长度为零。4.What happens if you attempt to use a variable before it has been initialized?
A A syntax error may be generated by the compiler
B A runtime error may occur during execution
C A "garbage" or "uninitialized" value will be used in the computation
D A value of zero is used if a variable has not been initialized
E Answers A and B are correct
编译器多次能够检测到未初始化变量的尝试使用, 在这种情况下会产生语法错误。如果编译器使用转义检测, 则在使用时会发生运行时错误。5.What is the function of the dot operator?
A It serves to separate the integer portion from the fractional portion of a floating point number
B It allows one to access the data within an object when given a reference to the object
C It allows one to invoke a method within an object when given a reference to the object
D It is used to terminate commands (much as a period terminates a sentence in English)
E Both B and C are correct
点算符的功能为:它允许在给定对象的引用时访问对象中的数据,当给定对象的引用时,它允许在对象中调用方法。所以这道题应该选e的。6.Unlike the String class where you must pass a message to an object (instance) of the class, as in x.length( ), in order to use the Math class, you pass messages directly to the class name, as in Math.abs( ) or Math.sqrt( ).
A .true
B .false
数学类使用被称为静态方法 (或类方法) 的方法, 通过将消息直接传递到类名本身而不是类的对象来调用。7.Which of the following will yield a pseudorandom number in the range [ -5, +5 ) given the following:
Random gen = new Random( );
A . gen.nextFloat( ) * 5
B . gen.nextFloat( ) * 10 - 5
C . gen.nextFloat( ) * 5 - 10
D . gen.nextInt( ) * 10 - 5
E . gen.nextInt(10) - 5
gen.nextInt(10) - 5 所得到的结果是-5,-4,-3,-2,-1,0,1,2,3,4,并不是题目中所要求的,它得到的只是一些数而不是一个取值范围。而nextFloat则是在范围[0,1)中产生伪随机数字;乘以10的收益率在0到10之间,再减去5,得到结果。8.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 objects
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
这两个声明都是合法的Java。s1是一个字符串引用,它被初始化为字符串“testing123”。s2是一个字符串引用,它被初始化为字符串“测试123”。注意“测试”和“123”之间的空格。所以这两个字符串不相等。9.An "alias"(别名) is when
A . two different reference variables refer to the same physical object
B . two different numeric variables refer to the same physical object
C . two different numeric variables contain identical values
D . two variables have the same names
E . none of the above
当有两个或多个对同一物理对象的引用时,就会出现“别名”,这样,通过遵循任一引用,就可以读/写/修改对象10.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
如果两个字符串是完全一致的,那么它的值为0。11.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
伪随机数生成器相对于Math.random的优势在于:可以创建几个随机数生成器,可以在一个范围内生成随机的int,floats和ints。所以应该包括A与B。12.If you need to import not only the top-level of a package, but all its secondary levels as well, you should write: import package..;
A true
B false
如果您不仅需要导入包的顶层, 而且还要输入所有的辅助级别, 则应编写: 导入包. ;(false);导入包.13.You may use the String replace( ) method to remove characters from a String.
A true
B false
replace()方法仅用其他单个字符替换单个字符。replace()方法不会将字符添加或删除字符串;字符串长度将保持不变14.All the methods in the Math class are declared to be static.
A true
B false
数学类方法被设计成在算术表达式中通常有用,因此不需要任何实例来使用它们。这是通过确保所有的数学方法都是静态的来实现的。15.The advantage(s) of the Random class' pseudo-random number generators, compared to the Math.random method, is that
A . you may create several random number generators
B . the generators in Random are more efficient than the one in Math.random
C . you can generate random ints, floats, and ints within a range
D . you can initialize and reinitialize Random generators
E . all but answer B
所有随机数字生成器的效率是一样的。随机生成器优于数学的优点。随机包含所有其他属性。16.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
通过一个或多个数学方法,截断在程序员的手中“%”符号会出现在显示器的末端,而不是开始。
20172325 2016-2017-2 《Java程序设计》第四周学习总结的更多相关文章
- Java程序设计第四周学习总结
1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 答:①String类是final类,不能定义String的子类. ② instanceof ...
- 对于“2017面向对象程序设计(JAVA)第四周学习总结”存在问题的反馈
对于“2017面向对象程序设计(JAVA)第四周学习总结”存在问题的反馈 “这部分同学博文总结没有写,实验作业没有提交.”——1.关于博文作业.实验作业教学功能的正解:学习知识.暴露问题.衔接课上.2 ...
- 杨其菊201771010134《面向对象程序设计(java)》第四周学习总结
<面向对象程序设计(java)> 第四周学习总结 第一部分:理论知识 1.类与对象 a.类(class)是构造对象的模板或蓝图.由类构造对象的过程称为创建类的实例: java中类声明的格式 ...
- 201871010106-丁宣元 《面向对象程序设计(java)》第四周学习总结
201871010106-丁宣元 <面向对象程序设计(java)>第四周学习总结 正文开头 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-da ...
- 20155318 2016-2017-2 《Java程序设计》第九学习总结
20155318 2016-2017-2 <Java程序设计>第九学习总结 教材学习内容总结 学习目标 了解JDBC架构 掌握JDBC架构 掌握反射与ClassLoader 了解自定义泛型 ...
- 《Java程序设计》第二学习总结
<Java程序设计>第二学习总结 教材学习内容总结 类型 byte(字节) shot(短整型) int(整型) long(长整型) float(浮点型) double(双精度) char( ...
- 20145304 刘钦令 Java程序设计第二周学习总结
20145304 <Java程序设计>第2周学习总结 教材学习内容总结 java可区分基本类型和类类型(即参考类型)两大类型系统. 基本类型主要可区分为整数.字节.浮点数.字符与布尔. 整 ...
- 20145304 刘钦令 Java程序设计第一周学习总结
20145304<Java程序设计>第1周学习总结 教材学习内容总结 1995年5月23日,是公认的Java的诞生日,Java正式由Oak改名为Java. Java的三大平台是:Java ...
- 20145120黄玄曦 《java程序设计》 寒假学习总结
1和2.我对未来规划不多,我认为好好学习积累知识能帮助我应对未来的挑战,这是我的学习动力之一,此外,了解新知识满足好奇心也是我的主要的学习动力. 3.我认为专业课学习比公务员考试重要,我认为专业知识是 ...
- 201621123007 Java程序设计第一周 学习总结
第一周-Java基本概念 201621123007 <Java程序设计> 第一周学习总结 1. 本周学习总结 java是面向对象的一类语言,三大特征:封装性,继承性,多态性. jdk jr ...
随机推荐
- ASP.NET MVC中Section、Partial View 和 Child Action(转载)
概括的讲,View中的内容可以分为静态和动态两部分.静态内容一般是html元素,而动态内容指的是在应用程序运行的时候动态创建的内容.给View添加动态内容的方式可归纳为下面几种: Inline cod ...
- sqli-labs学习(less-5-less-7)
先介绍一些函数 count(*) 返回在给定的选择中被选的行数,即结果的数目 报错了,但是union没有出结果?,只是为什么? 原来是这样,这样的话只能用报错注入了 (). 通过floor报错 and ...
- 浅析 golang module
什么是 module?module 解决了什么问题? module 代表一个版本管理单元,它包括一个或者多个 packages. 一般来说,一个版本控制仓库(比如 golang.org/x/text ...
- Lint Code 1365. Minimum Cycle Section
这题可以看作POJ 1961 最小循环节的一个简化版本.某补习班广告贴里给出的两个指针的参考解法简直大误. 受POJ 1961的启发,把数组看作字串,观察可知,如果字串全部由循环节构成(包括最后一段是 ...
- jquery 获取checkbox的checked属性总是undefined
项目中用的jquery1.9 今天需要检测一个checkbox的选中状态,想当然的用 .attr("checked") ,结果发现,无论是否选中,这个值都是 undefined 未 ...
- RabbitMQ(四):RPC的实现
原文:RabbitMQ(四):RPC的实现 一.RPC RPC(Remote Procedure Call)—远程过程调用,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议. ...
- 【TJOI2017】DNA
题面 题解 对字符串一脸懵的我肯定只能用$FFT$这种暴力方法水过啊... 将后面那个字符串翻转一下,对$\text{AGCT}$分别统计,用$FFT$就可以啦 代码 #include<cstd ...
- spark遇到的一些问题及其解决办法
1.报错:ERROR storage.DiskBlockObjectWriter: Uncaught exception while reverting partial writes to file ...
- set方法在set传入值时报空指针异常,直接设置定值即可
这种情况可能跟上下的程序有关,所以直接设置定值传入即可. 例如: re.setRid(ar.getRid()); // 这个是报错代码 md.setConnMailStatusTrue(ar.getR ...
- Git的原理简介和常用命令
Git和SVN是我们最常用的版本控制系(Version Control System, VCS),当然,除了这二者之外还有许多其他的VCS,例如早期的CVS等.顾名思义,版本控制系统主要就是控制.协调 ...