20172333 2017-2018-2 《Java程序设计》第4周学习总结
20172333 2017-2018-2 《Java程序设计》第4周学习总结
教材学习内容
1.类结构的定义与概念
2.利用实例数据建立对象状态的概念
3.描述可见性修饰符作用在方法和数据上的效果
4.学习方法参数与返回值的运用
5.构造方法的结构和用途
6.学习了面向对象软件设计的主要步骤
7.程序所需的类和对象的技术
8.类之间的三种关系
9.Static在方法的作用效果
10.静态变量,静态方法,非静态方法,非静态变量的差别
11.this应用语句
12.接口
13.枚举类型
代码调试中的问题和解决过程
[x] 问题1:刚开始做的使用Die的方法的Java程序,未提前声明类,导致一直报错。

解决过程: 在重复改正无效后,参考书上后尝试将后面的Die.java程序编译运行后,再度运行RollingDice.java,最终成功。


[x] 问题2:在进行PP4.9的程序编译时,题目要求使用之前的Die类文件并重新定义新的类,发生如图错误。

解决过程:我试图在书上寻找相关资料看是否可以解决该问题,但是并没有发现有明确的方法,我开始从头开始寻找错误,我突然想到在使用Die的话,就需要Die.class文件在该目录下,于是重新编译了一遍Die.class,结果问题还是没有解决,后来想起在RoolingDice.java中引用Die.java时要实例化,就在PairOfDice.Java中实例化了两个变量。错误就迎刃而解了。





教材学习中的问题和解决过程
- [x] 问题1:如何将对象作为参数进行传递?
- 解决过程:这道题我是在Sr7.21上看到的,我的理解是将对象里的实例数据赋值与某个参数,以这个参数进行传递。事实上答案解析却是将这个对象的引用副本复制给该方法,使该方法的实参和形参互相成为了对方的别名。
代码托管

(statistics.sh脚本的运行结果截图)
上周考试错题总结
1.The relationship between a class and an object is best described as
A . classes are instances of objects
B . objects are instances of classes
C . objects and classes are the same thing
D . classes are programs while objects are
variables
E . objects are the instance data of classes
总结:类中包含实例数据与方法,而对象就是实例化的数据。
- In order to preserve encapsulation of an object, we would do all of the following except for which one?
A . Make the instance data private
B . Define the methods in the class to access and manipulate the instance data
C . Make the methods of the class public
D . Make the class final
E . All of the above preserve encapsulation
总结:封装意味着该类包含了操纵数据所需的数据和方法。为了正确地保存封装,实例数据不应该直接从类之外访问,因此实例数据是私有的,并且定义了方法来访问和操纵实例数据。此外,访问和操纵实例数据的方法被公开,以便其他类可以使用该对象。
3.If a method does not have a return statement, then
A . it will produce a syntax error when compiled
B . it must be a void method
C . it can not be called from outside the class that defined the method
D . it must be defined to be a public method
E . it must be an int, double, float or String method
总结:只有void方法不用返回,其余的都有相应的返回值。
4.Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?
A . m1
B . m2
C . m3
D . m5
E . main
总结:一旦方法终止,方法里的值便会恢复。
5.Consider a Rational class designed to represent rational numbers as a pair of int's, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int's), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.
A . Because they will never be used
B . Because they will only be called from
methods inside of Rational
C . Because they will only be called from the constructor of Rational
D . Because they do not use any of Rational's instance data
E . Because it is a typo and they should be declared as public
总结:私有定义只能在本类之中使用。
- In black-box testing, the tester should already know something about how the program is implemented so that he/she can more carefully identify what portion(s) of the software are leading to errors.
A . true
B . false
总结:黑盒实验,程序员只是知道输入与输出,不知道其具体方法,一点知道方法便变成了透明盒实验了。
7.Interface classes cannot be extended but classes that implement interfaces can be extended.
A . true
B . false
总结:除了Final不可扩展,其余均可拓展。
8.Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
A . true
B . false
总结:形参是方法头里面的,实参是方法内部的参数。
9.Assume that the class Bird has a static methodfly( ). If b is a Bird, then to invoke fly, you could do Bird.fly( );.
A . true
B . false
总结:静态方法所有都共享。
10.The goal of testing is to
A . ensure that the software has no errors
B . find syntax errors
C . find logical and run-time errors
D . evaluate how well the software meets the original requirements
E . give out-of-work programmers something to do
总结:测试Java程序是为了确保程序逻辑错误不出现。
学习进度条
| 代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
|---|---|---|---|---|
| 目标 | 5000行 | 30篇 | 400小时 | |
| 第一周 | 125/125 | 2/2 | 20/20 | |
| 第二周 | 269/394 | 2/4 | 未知/38 | |
| 第三周 | 477/920 | 1/5 | X/X | |
| 第四周 | 1179/2338 | 1/6 | -- |




20172333 2017-2018-2 《Java程序设计》第4周学习总结的更多相关文章
- 学号 20175212 《Java程序设计》第九周学习总结
学号 20175212 <Java程序设计>第九周学习总结 教材学习内容总结 一.MySQL数据库管理系统 1.在官网上下载并安装MySQL 2.在IDEA中输入测试代码Connectio ...
- 20145213《Java程序设计》第九周学习总结
20145213<Java程序设计>第九周学习总结 教材学习总结 "五一"假期过得太快,就像龙卷风.没有一点点防备,就与Java博客撞个满怀.在这个普天同庆的节日里,根 ...
- 20145213《Java程序设计》第二周学习总结
20145213<Java程序设计>第二周学习总结 教材学习内容总结 本周娄老师给的任务是学习教材的第三章--基础语法.其实我觉得还蛮轻松的,因为在翻开厚重的书本,一股熟悉的气息扑面而来, ...
- 20145213《Java程序设计》第一周学习总结
20145213<Java程序设计>第一周学习总结 教材学习内容总结 期待了一个寒假,终于见识到了神秘的娄老师和他的Java课.虽说算不上金风玉露一相逢,没有胜却人间无数也是情理之中,但娄 ...
- 21045308刘昊阳 《Java程序设计》第九周学习总结
21045308刘昊阳 <Java程序设计>第九周学习总结 教材学习内容总结 第16章 整合数据库 16.1 JDBC入门 16.1.1 JDBC简介 数据库本身是个独立运行的应用程序 撰 ...
- 20145330孙文馨 《Java程序设计》第一周学习总结
20145330孙文馨 <Java程序设计>第一周学习总结 教材学习内容总结 刚开始拿到这么厚一本书说没有压力是不可能的,开始从头看觉得很陌生进入不了状态,就稍微会有一点焦虑的感觉.于是就 ...
- 20145337 《Java程序设计》第九周学习总结
20145337 <Java程序设计>第九周学习总结 教材学习内容总结 数据库本身是个独立运行的应用程序 撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的增删查找 JDBC可以 ...
- 20145337 《Java程序设计》第二周学习总结
20145337 <Java程序设计>第二周学习总结 教材学习内容总结 Java可分基本类型与类类型: 基本类型分整数(short.int.long).字节(byte).浮点数(float ...
- 20145218《Java程序设计》第一周学习总结
20145218 <Java程序设计>第一周学习总结 教材学习内容总结 今天下午看了Java学习的视频,感觉很是新奇,之前觉得Java学起来是艰难枯燥的,但通过第一章的学习觉得如果自己可以 ...
- 《Java程序设计》第九周学习总结
20145224 <Java程序设计>第九周学习总结 第十六章 整合数据库 JDBC入门 ·数据库本身是个独立运行的应用程序 ·撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的 ...
随机推荐
- Python参数输入模块-optparse
废话: 模块名是optparse, 很多人打成optparser.以至于我一直导入导入不了.搞的不知所以. 模块的使用: import optparse #usage 定义的是使用方法,%prog 表 ...
- sublime3插件安装及报错处理
ctrl+shift+p调用出窗口:输入install package,然后输入想安装的插件. 有些用户安装的可能是国内破解版的,我的就是,然后install package报错: Package C ...
- 【Python学习笔记】异常处理try-except
Python异常处理 我们一般使用try-except语句来进行异常处理. 使用except Exception as err可以统一捕捉所有异常,而也可以分开处理单个异常. # 分开捕捉单个异常 t ...
- 多线程伪共享FalseSharing
1. 伪共享产生: 在SMP架构的系统中,每个CPU核心都有自己的cache,当多个线程在不同的核心上,并且某线程修改了在同一个cache line中的数据时,由于cache一致性原则,其他核心cac ...
- ftrace 简介【转】
转自:http://www.ibm.com/developerworks/cn/linux/l-cn-ftrace/index.html Trace 对于软件的维护和性能分析至关重要,ftrace 是 ...
- C基础 多用户分级日志库 sclog
引言 - sclog 总的设计思路 sclog在之前已经内置到simplec 简易c开发框架中一个日志库. 最近对其重新设计了一下. 减少了对外暴露的接口. 也是C开发中一个轮子. 比较简单, 非常适 ...
- android intent 传数据
1. 基本数据类型 Intent intent = new Intent(); intent.setClass(activity1.this, activity2.class); //描述起点和目标 ...
- Leetcode 之Binary Tree Preorder Traversal(42)
树的先序遍历.定义一个栈,先压入中间结点并访问,然后依次压入右.左结点并访问. vector<int> preorderTraversal(TreeNode *root) { vector ...
- three.js、webGL、canvas区别于关联
canvas是html5新定义的一个标签,用于做图形容器 webgl要依赖canvas运行. three.js是以webgl为基础的库,封装了一些3D渲染需求中重要的工具方法与渲染循环.
- LeetCode解题报告—— Bus Routes
We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For e ...