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

教材学习内容总结

  • 了解NIO
  • 会使用Channel、Buffer与NIO2
  • 会使用日志API、国际化
  • 会使用正则表达式
  • 了解JDK8增强功能

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

课后习题

所谓“实践是检验认识真理性的唯一标准”,我在IntelliJ IDEA上把教材第三章课后练习题又敲了一

遍,给出了自己的答案,并加上了一些自己的分析,通过逐题进行代码调试实践的方式来深入对java类与对象的理解。小白在此恳请大家积极指出错误的地方(>_<)

9.4.1 选择题

  1. CD 分析:

     import java.util.*;
    import java.util.ArrayList;
    public class Exercise9411 {
    public static void main(String[] args) {
    foreach(new HashSet());
    foreach(new ArrayList());
    }
    private static void foreach(Collection elements) {
    for(Object o : elements) { }
    }
    }





  2. AB 分析:

     import java.util.*;
    //import java.util.ArrayList; public class Exercise9412 {
    public static void main(String[] args) {
    foreach(new HashSet() {
    });
    }
    private static void foreach(Iterable iterable) {
    for(Object o : iterable) { }
    }
    }







  3. C 分析:

     import java.util.*;
    public class Exercise9413 {
    public static void main(String[] args) {
    foreach(new HashSet());
    }
    private static void foreach(Collection collection) {
    Iterator elements = collection.iterator();
    while(elements.hasNext()) {
    System.out.println(elements.next());
    }
    }
    }





  4. D 分析:

     import java.util.*;
    class Student9414 {
    String number;
    String name;
    int score;
    Student9414(String number, String name, int score) {
    this.number = number;
    this.name = name;
    this.score = score;
    }
    }
    public class Exercise9414 {
    public static void main(String[] args) {
    Set<Student9414> students = new TreeSet<>();
    students.add(new Student9414("B1234", "Justin", 90));
    students.add(new Student9414("B5678", "Monica", 100));
    foreach(students);
    }
    private static void foreach(Collection<Student9414> students) {
    for(Student9414 student : students) {
    System.out.println(student.score);
    }
    }
    }

  5. D 分析:

     import java.util.*;
    class Student9415 {
    String number;
    String name;
    int score;
    Student9415(String number, String name, int score) {
    this.number = number;
    this.name = name;
    this.score = score;
    }
    }
    public class Exercise9415 {
    public static void main(String[] args) {
    Set<Student9415> students = new HashSet<>();
    students.add(new Student9415("B1234", "Justin", 90));
    students.add(new Student9415("B5678", "Monica", 100));
    students.add(new Student9415("B1234", "Justin", 100));
    students.add(new Student9415("B5678", "Monica", 98));
    students.add(new Student9415("B5678", "Monica", 100));
    System.out.println(students.size());
    }
    }

  6. A 分析:

     import java.util.*;
    public class Exercise9416 {
    public static void main(String[] args) {
    Set<Integer> numbers = new TreeSet<>();
    numbers.add(1);
    numbers.add(2);
    numbers.add(1);
    numbers.add(3);
    foreach(numbers);
    }
    private static void foreach(Collection<Integer> numbers) {
    for(Integer number : numbers) {
    System.out.println(number);
    }
    }
    }

  7. ABC

  8. C

     import java.util.*;
    public class Exercise9418 {
    public static void main(String[] args) {
    Set numbers = new TreeSet();
    numbers.add(1);
    numbers.add(2);
    numbers.add(1);
    numbers.add(3);
    for(Integer number : numbers) {
    System.out.println(number);
    }
    }
    }

  9. C 分析:

     import java.util.*;
    public class Exercise9419 {
    public static void main(String[] args) {
    Set<Integer> numbers = new TreeSet<>();
    numbers.add(1);
    numbers.add(2);
    numbers.add(1);
    numbers.add(3);
    for(Integer number : numbers) {
    System.out.println(number);
    }
    }
    }







  10. CD

    import java.util.*;
    public class Exercise94110 {
    public static void main(String[] args) {
    Map<String, String> messages = new HashMap<>();
    messages.put("Justin", "Hello");
    messages.put("Monica", "HiHi");
    foreach(messages.values());
    }
    private static void foreach(Iterable<String> values) {
    for(String value : values) {
    System.out.println(value);
    }
    }
    }





10.4.1 选择题

  1. AC

  2. BD

  3. AC

  4. BD

    分析:

  5. A

    分析:

     import java.util.*;
    class Student9415 {
    String number;
    String name;
    int score;
    Student9415(String number, String name, int score) {
    this.number = number;
    this.name = name;
    this.score = score;
    }
    }
    public class Exercise9415 {
    public static void main(String[] args) {
    Set<Student9415> students = new HashSet<>();
    students.add(new Student9415("B1234", "Justin", 90));
    students.add(new Student9415("B5678", "Monica", 100));
    students.add(new Student9415("B1234", "Justin", 100));
    students.add(new Student9415("B5678", "Monica", 98));
    students.add(new Student9415("B5678", "Monica", 100));
    System.out.println(students.size());
    }
    }

  6. BC 分析:

     import java.util.*;
    public class Exercise9416 {
    public static void main(String[] args) {
    Set<Integer> numbers = new TreeSet<>();
    numbers.add(1);
    numbers.add(2);
    numbers.add(1);
    numbers.add(3);
    foreach(numbers);
    }
    private static void foreach(Collection<Integer> numbers) {
    for(Integer number : numbers) {
    System.out.println(number);
    }
    }
    }



  7. BC

  8. BD

  9. D

    错选:B

  10. ABD

    错选:AD

    分析:



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

  • 帮助20155324王鸣宇同学解决了Linux命令行下git commit和git push的问题~为此鸣宇还专门写了一篇博客记录下我们探索的详细过程~总之挺有成就感的嘻嘻( ̀⌄ ́)

    如何解决无法成功git commit 和git push

  • 关于20155322秦诗茂同学macOS下Vim编码问题(已解决,改为UTF-8即可)

代码托管

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



上周考试错题总结

本周第二次采用了在蓝墨云班课上考试的形式,在45分钟的时间里需要作答20道选择题,而且还有不少多选题,甚至大多都是程序分析题,一道一道敲到电脑上再去运行肯定是来不及的(>_<),更要命的是很多题不去跑程序的话我根本无从下手(>o<)所以还是老老实实学扎实才是万全之策啊~

  • 下面哪些Linux 命令可以ASCII码和16进制单字节方法输出Hello.java的内容?

    • A .od -b -tx1 Hello.java
    • B .od -tcx1 Hello.java
    • C .od -tc -tx1 Hello.java
    • D .od -tbx1 Hello.java

      正确答案: B C

      我的答案: C

      分析:-b 是以八进制输出
  • JDK8 中新时间API中,用于度量时间的类有()

    • A .Instant
    • B .Duration
    • C .Period
    • D .LocalDateTime

      正确答案: B C

      你的答案: A D

      分析:p442
  • An object can be thought of as a blueprint for a set of classes(对象被认为是类集合的蓝图).

    • A .true
    • B .false

      正确答案: B

      我的答案: A

      分析:A class can be thought of as a blueprint for a set of objects; not the other way around.
  • When an object is passed to a method, the actual and formal parameters become aliases(当把对象传递给方法时,实参和形参互为别名).

    • A .true
    • B .false

    正确答案: A

    我的答案: B

    分析:Actual parameters are the datum that are sent into the method. The formal parameters are used in the method definition. When objects are sent to a method, both of these values are references, and they become aliases of one another.

  • Which of the following objects could contain the information “eastern standard time”?(下面哪些类的对象会包含“东部标准时间”的信息)

    (Choose all that apply.)

    • A .Instant
    • B .LocalDate
    • C .LocalDateTime
    • D .LocalTime
    • E .ZonedDateTime

    正确答案: E

    我的答案: A E

    分析:LocalXXXX explicitly excludes time zones. Instant represents a point in time, but

    always uses GMT rather than the desired time zone.

  • Which of the following are stored in a Period object? (Choose all that apply.) 下面哪些内容会出现在Period对象中?

    • A .Year
    • B .Month
    • C .Day
    • D .Hour
    • E .Minute
    • F .Second

    正确答案: A B C

    我的答案: A B C D E F

    分析:Remember that Duration uses hours/minutes/seconds and Period uses years/

    months/days for measures.

  • Given the following, which answers can correctly fill in the blank? (Choose all that apply.)针对下面的代码,()中应填入哪个选项?

    LocalDate date = LocalDate.now();

    LocalTime time = LocalTime.now();

    LocalDateTime dateTime = LocalDateTime.now();

    ZoneId zoneId = ZoneId.systemDefault();

    ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, zoneId);

    long epochSeconds = 0;

    Instant instant = ( );

    • A .Instant.now()
    • B .Instant.ofEpochSecond(epochSeconds)
    • C .date.toInstant()
    • D .dateTime.toInstant()
    • E .time.toInstant()
    • F .zonedDateTime.toInstant()

    正确答案: F

    我的答案: A

    分析:Option A correctly creates the current instant. Option B correctly converts from

    seconds to an Instant. Option F is also a proper conversion. Options C, D, and E are

    incorrect because the source object does not represent a point in time. Without a time zone,

    Java doesn’t know what moment in time to use for the Instant.

结对及互评

评分标准

  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

  • 参考示例

点评过的同学博客和代码

感悟

学期过半,北京也开始由春转夏、渐渐炎热了。这周终于算是将Java前9章学完了~前9章主要讲解的是Java核心和面向对象思想,后面从第10章开始都是关于使用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
第七周 3119/6476 2/11 13/85 ①蹭了一节张健毅老师的Java课;②在写了无数篇实验报告之后还写了两篇博客!!
第八周 / 1/12 10/95
  • 计划学习时间:12小时

  • 实际学习时间:10小时

参考资料

20155314 2016-2017-2 《Java程序设计》第8周学习总结的更多相关文章

  1. 20155336 2016-2017-2《JAVA程序设计》第九周学习总结

    20155336 2016-2017-2<JAVA程序设计>第九周学习总结 教材学习内容总结 第十六章 JDBC(Java DataBase Connectivity)即java数据库连接 ...

  2. 20145213《Java程序设计》第九周学习总结

    20145213<Java程序设计>第九周学习总结 教材学习总结 "五一"假期过得太快,就像龙卷风.没有一点点防备,就与Java博客撞个满怀.在这个普天同庆的节日里,根 ...

  3. 20145213《Java程序设计》第二周学习总结

    20145213<Java程序设计>第二周学习总结 教材学习内容总结 本周娄老师给的任务是学习教材的第三章--基础语法.其实我觉得还蛮轻松的,因为在翻开厚重的书本,一股熟悉的气息扑面而来, ...

  4. 20145213《Java程序设计》第一周学习总结

    20145213<Java程序设计>第一周学习总结 教材学习内容总结 期待了一个寒假,终于见识到了神秘的娄老师和他的Java课.虽说算不上金风玉露一相逢,没有胜却人间无数也是情理之中,但娄 ...

  5. 21045308刘昊阳 《Java程序设计》第九周学习总结

    21045308刘昊阳 <Java程序设计>第九周学习总结 教材学习内容总结 第16章 整合数据库 16.1 JDBC入门 16.1.1 JDBC简介 数据库本身是个独立运行的应用程序 撰 ...

  6. 20145330孙文馨 《Java程序设计》第一周学习总结

    20145330孙文馨 <Java程序设计>第一周学习总结 教材学习内容总结 刚开始拿到这么厚一本书说没有压力是不可能的,开始从头看觉得很陌生进入不了状态,就稍微会有一点焦虑的感觉.于是就 ...

  7. 20145337 《Java程序设计》第九周学习总结

    20145337 <Java程序设计>第九周学习总结 教材学习内容总结 数据库本身是个独立运行的应用程序 撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的增删查找 JDBC可以 ...

  8. 20145337 《Java程序设计》第二周学习总结

    20145337 <Java程序设计>第二周学习总结 教材学习内容总结 Java可分基本类型与类类型: 基本类型分整数(short.int.long).字节(byte).浮点数(float ...

  9. 20145218《Java程序设计》第一周学习总结

    20145218 <Java程序设计>第一周学习总结 教材学习内容总结 今天下午看了Java学习的视频,感觉很是新奇,之前觉得Java学起来是艰难枯燥的,但通过第一章的学习觉得如果自己可以 ...

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

    20145224 <Java程序设计>第九周学习总结 第十六章 整合数据库 JDBC入门 ·数据库本身是个独立运行的应用程序 ·撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的 ...

随机推荐

  1. 【Android】Scroller分析

    mScroller.getCurrX() //获取mScroller当前水平滚动的位置 mScroller.getCurrY() //获取mScroller当前竖直滚动的位置 mScroller.ge ...

  2. Spring学习总结之高级装配

    1.  profile profile可以决定bean在什么环境下才被装配(开发环境.测试环境.线上环境等) @Profile(“dev”)可以用在class之前,也可以用在类之前(Spring3.2 ...

  3. 用IDEA开发简单的Servlet

    最近学习java,主要是servlet相关的内容.IDEA和servlet之前都没有碰过,所以做了一下小实验,走了一些弯路:这里把一个完整的步骤写出来,加深一下印象. IDEA创建项目步骤 1. 在i ...

  4. RYU 的选择以及安装

    RYU 的选择以及安装 由于近期的项目需求,不得已得了解一下控制器内部发现拓扑原理,由于某某应用中的控制器介绍中使用的RYU,所以打算把RYU装一下试试.出乎意料的是,RYU竟是我之前装过最最轻便的控 ...

  5. opencv图像识别技术在自动化测试中的应用

    在自动化测试中,基于xpath.js选择器.css选择器进行元素定位及判定的技术已经比较成熟.在实际应用中,无论是web端还是移动端,仍有很多时候需要根据页面内容.页面中的图像进行定位及判定,这里介绍 ...

  6. Android 获取加速传感器的值,并去除杂音

    1.注册和注销传感器 private void registerSensor() { manager.registerListener(this, manager.getDefaultSensor(S ...

  7. Caffe搭建:Ubuntu14.04 + CUDA7.0 + opencv3.0 + Matlab2014A

    从Hinton在science上发表深度学习训练开创新的文章以来,深度学习火了整整有3年多,而且随着新的硬件和算法的提出,深度学习正在应用于越来越多的领域,发挥其算法的优势. 实验室并没有赶上第一波深 ...

  8. oracle-表空间剩余空间大小占比查询

    select tablespace_name, max_gb, used_gb, round(100 * used_gb / max_gb) pct_used from (select a.table ...

  9. 获取androdmanifest里面的meta-data

    /* * Copyright 2017 JessYan * * Licensed under the Apache License, Version 2.0 (the "License&qu ...

  10. 【BZOJ1295】[SCOI2009]最长距离(最短路)

    [BZOJ1295][SCOI2009]最长距离(最短路) 题面 BZOJ 洛谷 题解 这题很妙啊. 我们枚举一个点,只需要考虑到他的最远点就行了,显然只需要考虑一个点即可.那么这两个点之前联通的最小 ...