20155314 2016-2017-2 《Java程序设计》第6周学习总结

教材学习内容总结

  • 理解流与IO
  • 理解InputStream/OutPutStream的继承架构
  • 理解Reader/Writer继承架构
  • 会使用装饰类
  • 会使用多线程进行并发程序设计

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

课后习题

所谓“实践是检验认识真理性的唯一标准”,我在IntelliJ IDEA上把教材第三章课后练习题又敲了一遍,给出了自己的答案,并加上了一些自己的分析,通过逐题进行代码调试实践的方式来深入对java类与对象的理解。小白在此恳请大家积极指出错误的地方(>_<)

8.4.1 选择题

  1. C 分析:

     public class Exercise8411 {public static void main(String[] args) {try {int number=Integer.parseInt(args[0]);System.out.println(number++);}catch (NumberFormatException ex) {System.out.println("必须输入数字");}}}

  2. C 分析:

     public class Exercise8412 {public static void main(String[] args) {Object[] objs={"Java","7"};Integer number=(Integer)objs[1];System.out.println(number);}}

  3. B 分析:

     public class Exercise8413 {public static void main(String[] args) {try {int number=Integer.parseInt(args[0]);System.out.println(number++);}catch (NumberFormatException ex) {System.out.println("必须输入数字");}}}



  4. ACD 分析:

     public class Exercise8414 {public static String readFile(String name) throws Throwable{FileInputStream input=new FileInputStream(name);return input.toString();}}

  5. ACD 分析:

     public class Exercise8415 {public static String readFile(String name) {FileInputStream input=null;try {input=new FileInputStream(name);}catch (FileNotFoundException ex) {}return input.toString();}}

  6. CD 分析:

     class Exercise8416 {void doService() throws IOException {}}class exercise8416 extends Exercise8416 {@Overridevoid doService() throws FileNotFoundException {}

    }

  7. B

     public class Exercise8417 {public static void main(String[] args) {try {int number=Integer.parseInt(args[0]);System.out.println(number++);}catch (ArrayIndexOutOfBoundsException|NumberFormatException ex) {System.out.println("必须输入数字");}}}

  8. A

     public class Exercise8418 {public static void main(String[] args) {try {int number=Integer.parseInt(args[0]);System.out.println(number++);}catch (RuntimeException|NumberFormatException ex) {System.out.println("必须输入数字");}}}

  9. A 分析:

     public class Exercise8419 {public static String readFile(String name) {try(FileInputStream input=new FileInputStream(name)) {}}}

  10. A

    public class Exercise84110 {public static void main(String[] args) {try(ResourceSome84110 some=new ResourceSome84110();ResourceOther84110 other=new ResourceOther84110()) {some.doSome();other.doOther();}catch (Exception ex) {ex.printStackTrace();}}
    }class ResourceSome84110 implements AutoCloseable {void doSome() {out.println("做一些事");}@Overridepublic void close() throws Exception {out.println("资源Some被关闭");}
    }class ResourceOther84110 implements AutoCloseable {void doOther() {out.println("做其他事");}@Overridepublic void close() throws Exception {out.println("资源Other被关闭");}

    }

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

  • 关于Java中非法输入的若干探索

    以课本P228—229代码为例:



代码托管

(statistics.sh脚本的运行结果截图)


上周考试错题总结

本周第一次采用了在蓝墨云班课上考试的形式,虽然最后因为很多同学提交失败而仅当练手,不过说实在的这种新颖的考试形式也给我敲了警钟——在25分钟的时间里需要作答30道选择题,而且还有不少多选题,甚至大多都是程序分析题,一道一道敲到电脑上再去运行肯定是来不及的(>_<),更要命的是很多题不去跑程序的话我根本无从下手(>o<)所以还是老老实实学扎实才是万全之策啊~

  • 已知某用户stud1,其用户目录为/home/stud1。如果当前目录为/home,使用一下哪个命令后可以进入/home/stud1/test?

    • A .cd home
    • B .cd stud1/test
    • C .cd /stud1/test
    • D .cd test

    正确答案: B
    我的答案: D
    分析:cd 等价于cd ~,也就是cd /home/userXXX

  • Which of the following methods will not compile?
    • A .

        private void method1(String name) {if (name.equals("star"))throw new IllegalArgumentException(name);} 
    • B .

        private void method2(int age) {if (age > 30)throw Exception();} 
    • C .

        public double method5() throws Exception {return 0.7;} 
    • D .

        protected double method4() throws Exception {throw new Throwable();} 

      正确答案: B D

      分析:Methods that compile successfully might not be implemented correctly.
      This question only asks about the methods that will follow the syntax rules so that they
      compile successfully.
      Option (a) code compiles successfully. Because IllegalArgumentException is a
      runtime exception, method1() can throw it without declaring it to be thrown in its
      throws statement.
      Option (b) code won’t compile. method2() throws a checked exception, that is,
      Exception, without declaring it to be thrown in its throws statement.
      Although the code in option. A
      method can throw a StackOverflowError (an unchecked exception) without including it in the throws clause of its method declaration.
      Option (d) code won’t compile. If a method declares to throw a checked exception, its body can’t throw a more general exception in its body. method4() declares to
      throw Exception but throws Throwable, which is not allowed (Exception subclasses
      Throwable).
      Option (c) code will compile successfully. If a method declares to throw Exception,
      it might not actually throw it. This only applies to Exception (because RuntimeException subclasses it), runtime exceptions, and errors

  • What is the output of the following code?

      class EJava {void method() {try {guru();return;} finally {System.out.println("finally 1");}}void guru() {System.out.println("guru");throw new StackOverflowError();}public static void main(String args[]) {EJava var = new EJava();var.method();}}
    • A .
      guru
      finally 1
    • B .
      guru
      finally 1
      Exception in thread "main" java.lang.StackOverflowError
    • C .
      guru
      Exception in thread "main" java.lang.StackOverflowError
    • D .
      guru
    • E .
      The code fails to compile.

    正确答案: B

    分析:No compilation errors exist with the code.
    The method guru throws StackOverflowError, which is not a checked exception.
    Even though your code shouldn’t throw an error, it is possible syntactically. Your code
    will compile successfully.
    The call to the method guru is immediately followed by the keyword return, which is
    supposed to end the execution of the method method. But the call to guru is placed
    within a try-catch block, with a finally block. Because guru doesn’t handle the error
    StackOverflowError itself, the control looks for the exception handler in the method
    method. This calling method doesn’t handle this error but defines a finally block. The
    control then executes the finally block. Because the code can’t find an appropriate
    handler to handle this error, it propagates to the JVM, which abruptly halts the code.

结对及互评

评分标准

  1. 正确使用Markdown语法(加1分):

    • 不使用Markdown不加分
    • 有语法错误的不加分(链接打不开,表格不对,列表不正确...)
    • 排版混乱的不加分
  2. 模板中的要素齐全(加1分)
    • 缺少“教材学习中的问题和解决过程”的不加分
    • 缺少“代码调试中的问题和解决过程”的不加分
    • 代码托管不能打开的不加分
    • 缺少“结对及互评”的不能打开的不加分
    • 缺少“上周考试错题总结”的不能加分
    • 缺少“进度条”的不能加分
    • 缺少“参考资料”的不能加分
  3. 教材学习中的问题和解决过程, 一个问题加1分

  4. 代码调试中的问题和解决过程, 一个问题加1分

  5. 本周有效代码超过300分行的(加2分)
    • 一周提交次数少于20次的不加分
  6. 其他加分:
    • 周五前发博客的加1分
    • 感想,体会不假大空的加1分
    • 排版精美的加一分
    • 进度条中记录学习时间与改进情况的加1分
    • 有动手写新代码的加1分
    • 课后选择题有验证的加1分
    • 代码Commit Message规范的加1分
    • 错题学习深入的加1分
    • 点评认真,能指出博客和代码中的问题的加1分
    • 结对学习情况真实可信的加1分
  7. 扣分:
    • 有抄袭的扣至0分
    • 代码作弊的扣至0分
    • 迟交作业的扣至0分

点评模板:

  • 博客中值得学习的或问题:

    • xxx
    • xxx
    • ...
  • 代码中值得学习的或问题:
    • xxx
    • xxx
    • ...
  • 基于评分标准,我给本博客打分:XX分。得分情况如下:xxx

  • 参考示例

点评过的同学博客和代码

  • 本周结对学习情况

    • 20155323
    • 结对照片
    • 结对学习内容
      • 第四章 认识对象
      • 第五章 对象封装
  • 上周博客互评情况
    • 20145209
    • 20155218
    • 20155331
    • 20155336
    • 20155320

感悟

这周因为清明节放假调休上了六天课,特别是周六还补周一的课,又是满课的一天,烧脑的数据结构、密码学什么的真心累(>_<)(还记得数据结构课上张岩老师谜之微笑:正好咱们来好好讲讲)

生活充满节奏感?!!

其次这周二遭遇了史上第一次数据结构实验的洗礼(; ̄ェ ̄)

HP-2147483647(´-`)

也许是进入了瓶劲期了吧,感觉Java真的学不动了,难受(><)目前已经离老师布置的教学进程差了整整两章:(那又有什么办法呢只能老老实实按照自己的进度龟速向前爬呗~希望自己能在清明假期调整一下状态,争取迎头赶上吧……(。ì í。)

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 5000行 20篇 300小时
第一周 34/34 1/4 12/12
第二周 360/394 1/5 16/28
第三周 701/1018 1/6 19/ 47 代码量激增( ̀⌄ ́)
第四周 608/1375 1/7 18/55 ①蹭了一节张健毅老师的Java课;②自己将数据结构课上所学的排序算法除了基数排序之外全部用C语言实现了一遍(`_´)ゞ;③本次博客史无前例的长:)
第五周 1205/2580 1/8 9/64 蹭了一节张健毅老师的Java课
第六周 826/3339 1/9 8/72
  • 计划学习时间:12小时

  • 实际学习时间:8小时

参考资料

  • Java学习笔记(第8版)

  • 《Java学习笔记(第8版)》学习指导
  • 20155205 2016-2017-2 《Java程序设计》第4周学习总结

转载于:https://www.cnblogs.com/crazymosquito/p/6659808.html

20155314 2016-2017-2 《Java程序设计》第6周学习总结相关推荐

  1. 20175317 《Java程序设计》第一周学习总结

    20175317 <Java程序设计>第一周学习总结 教材学习内容总结 本周学习了Java大致的开发步骤,完成了课件自带的习题. 学习了在windows与Linux系统下不同的编译方法,掌 ...

  2. 20155227 2016-2017-2 《Java程序设计》第九周学习总结

    20155227 2016-2017-2 <Java程序设计>第九周学习总结 教材学习内容总结 JDBC简介 JDBC全名Java DataBase Connectivity,是java联 ...

  3. 20172318 2016-2017-2 《Java程序设计》第一周学习总结

    20172318 2016-2017-2 <Java程序设计>第一周学习总结 教材学习内容总结 在教材中基本明白了计算机系统的运行方式,了解了对于高级语言是使用是掌握好编程的关键,掌握了一 ...

  4. 20155303 2016-2017-2 《Java程序设计》第二周学习总结

    20155303 2016-2017-2 <Java程序设计>第二周学习总结 教材学习内容总结 『注意』 "//"为单行批注符: "/*"与&quo ...

  5. 20175208 《Java程序设计》第九周学习总结

    20175208 2018-2019-2 <Java程序设计>第九周学习总结 一.教材学习内容总结: 第11章 JDBC与MySQL数据库 MySQL数据库管理系统 MySQL数据库管理系 ...

  6. 20175204 张湲祯 2018-2019-2《Java程序设计》第九周学习总结

    20175204 张湲祯 2018-2019-2<Java程序设计>第九周学习总结 教材学习内容总结 -第十一章JDBC和MySQL数据库要点: 1.下载MySQL和客户端管理工具navi ...

  7. 20155313 2016-2017-2 《Java程序设计》第二周学习总结

    20155313 2016-2017-2 <Java程序设计>第二周学习总结 教材学习内容总结 1.1 基本类型 整数:可细分为short整数(占2字节).int整数(占4字节)与long ...

  8. 20155226 2016-2017-2 《Java程序设计》第一周学习总结

    20155226 2006-2007-2 <Java程序设计>第一周学习总结 教材学习内容总结 第一周主要学习了一二章的内容,也浏览了剩余章节,以下是本周主要学习内容总结 1.首先了解了[ ...

  9. 20172325 2018-2019-1 《Java程序设计》第二周学习总结

    20172325 2018-2019-1 <Java程序设计>第二周学习总结 教材学习内容总结 3.1集合 集合是一种聚集.组织了其他对象的对象.集合可以分为两大类:线性集合和非线性集合. ...

  10. 张旭升20162329 2006-2007-2 《Java程序设计》第一周学习总结

    20162329 2006-2007-2 <Java程序设计>第一周学习总结 教材学习内容总结 通过打书上的代码熟悉了Java编程的基本过程 教材学习中的问题和解决过程 1.因为我的虚拟机 ...

最新文章

  1. cocos2dx luajavaBridge 学习笔记
  2. 梁胜:做云计算,如何才能超越AWS?
  3. PowerDesigner反向生成物理数据模型
  4. c语言中栈区运用原理形象图,C语言实现使用动态数组来构造栈结构
  5. 用 Python 实现文件查找
  6. 语音信号短时域分析之预处理(三)
  7. Android微信视频播放填坑指南
  8. 记录一个海思TOE的BUG
  9. jboss eap 6.2 ear包 下使用log4j日志
  10. Docker是传统的应用发布管理的终结者么?
  11. android java.net.ConnectException: Connection 127.0.0.1:8080 refused
  12. 关于 错误 137 (net::ERR_NAME_RESOLUTION_FAILED) 的解决方案
  13. 【动态规划】P1057 传球游戏
  14. C++编程语言中类对象的赋值与复制介绍(三)
  15. 基于 SurfaceView 的直播点亮心形效果
  16. 机器翻译市场需求调研报告
  17. 项目经理要具备的三种能力
  18. 将本地图片或者网上图片用post方式上传到图片服务器
  19. Zynq-Linux移植学习-通过IIC访问RXS2448交换芯片
  20. 磁盘恢复工具OO DiskRecovery的使用

热门文章

  1. 最快速度求两个数组之交集算法
  2. baidu进阶训练笔记九20200727
  3. Deer计划(2)cloudcompare解析--八叉树
  4. 错误nested exception is org.apache.ibatis.binding.BindingException
  5. ahk2exe提示编译成功,但是没有文件输出,需要解决这个问题
  6. 微信公众号开发教程[001]-引言
  7. 【ZJOI 2009】狼和羊的故事
  8. Java初学多种数据类型接收方法总结
  9. httprunner3.x详细教程五(debugtalk.py介绍)
  10. 10月25日lol服务器维护,《LOL》维护到几点10月25日 英雄联盟10.25维护到几点结束...