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入门 ·数据库本身是个独立运行的应用程序 ·撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的 ...
随机推荐
- 使用BackgroundWorker
1,WPF应用程序为单线程模型(STAThread),所有UI控件都是主线程创建的,只有主线程能操作UI元素的显示. 2,其他工作线程要维护UI控件的显示,需调用主线程的Dispather,执行Inv ...
- perl6中的hash定义(1)
,,,); say %hash; , b => ); say %hash2; my %hash3 = (:name('root'), :host('localost')); say %hash3 ...
- AlertDialog.Builder 显示为白色 蓝色字
AlertDialog.Builder dialog = new AlertDialog.Builder( getActivity(),AlertDialog.THEME_HOLO_LIGHT);
- linux内核启动分析(3)
主要分析do_basic_setup函数里面的do_initcalls()函数,这个函数用来调用所有编译内核的驱动模块中的初始化函数. static void __init do_initcalls( ...
- 【jzoj2017.8.21提高组A】
太菜了,刷刷NOIP题玩玩. 今天的题好像以前有做过(雾) A. #include<bits/stdc++.h> typedef long long ll; ],cnt; ll x; in ...
- 获取file中字段,写入到TXT文件中
一下代码省略了很多,哈哈哈 a.txt文件 uid,type,pointx,pointy,name1,9,911233763,543857286,区间测速起点3,9,906371086,5453354 ...
- grep常见操作整理(更新)
提取邮箱和URL [root@test88 ~]# cat url_email.txt root@gmail.com,http://blog.peter.com,peter@qq.com [root@ ...
- Android studio 导入工程 出现错误
原文:http://blog.csdn.net/qazzxc111/article/details/48787419 对于刚开始使用Android studio 并且以前不了解gradle,IDE之类 ...
- FFT模板 生成函数 原根 多项式求逆 多项式开根
FFT #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> ...
- AC日记——[SDOI2009]HH去散步 洛谷 P2151
[SDOI2009]HH去散步 思路: 矩阵快速幂递推(类似弗洛伊德): 给大佬跪烂-- 代码: #include <bits/stdc++.h> using namespace std; ...