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

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) {
    
             }
         }
     }
    006HJ39wgy1fei0gredopj30z20k2tfq.jpg
    006HJ39wgy1fei0hduz4kj30x00mmtg4.jpg
    006HJ39wgy1fei0hs1kxwj30ym0iuq9j.jpg
  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) {
    
             }
         }
     }
    006HJ39wgy1fei0ij0lv9j30ts0dyn19.jpg
    006HJ39wgy1fei0j89zygj30vu06ital.jpg
    006HJ39wgy1fei0jkfb9bj30lc0rydjc.jpg
    006HJ39wgy1fei0juk30vj319m0cw78t.jpg
  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());
             }
         } 
     }
    006HJ39wgy1fei0kaplskj317e0mmtgd.jpg
    006HJ39wgy1fei0kohib4j30pw06idht.jpg
    006HJ39wgy1fei0l17fraj30ra06m40j.jpg
  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);
         }
         }
     }
    006HJ39wgy1fei0lgufo2j315w06kac1.jpg
  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());
         }
     }

    006HJ39wgy1fei0lumgvrj30dc03adg0.jpg

  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);
             } 
         }
     }
    c5fb24d138d34d1d.png
  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);
             }
         }
     }

    006HJ39wgy1fei0mhl0qjj31900e0gql.jpg

  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);
             }
         }
     }
    006HJ39wgy1fei0n88pt6j30vy0eeaen.jpg
    006HJ39wgy1fei0o5jjh8j30tm0uik2h.jpg
    006HJ39wgy1fei0odtro8j30vo0hcn1e.jpg
    006HJ39wgy1fei0ov7ci0j30rk0ucdqu.jpg
  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);
            }
        }
    }

    983be5c6aebe05f7.png
    983be5c6aebe05f7.png
    0110b9278af9fd79.png

10.4.1 选择题
  1. AC
  2. BD
  3. AC
  4. BD
    分析:
    49a679b09941be7e.jpg
  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());
         }
     }

    18886e11575f2f31.pnge322aaeb9291d9cb.pngb2d7333eeaf76eb0.pngd3488375b38fc514.png

  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);
             } 
         }
     }
    59833a4743bdf0f1.png
    9a751b758ca182e3.png
  7. BC
  8. BD
  9. D
    错选:B
  10. ABD
    错选:AD
    分析:
    63fda9471921a136.png
    7eca514d0695c537.png

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

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

    如何解决无法成功git commit 和git push
  • 关于20155322秦诗茂同学macOS下Vim编码问题(已解决,改为UTF-8即可)
    22d421c08f6765cd.png

    代码托管

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

006HJ39wgy1fei0ekoynaj317s0swdvj.jpg
006HJ39wgy1fei0fdm1bkj316i0r6atp.jpg

上周考试错题总结

本周第二次采用了在蓝墨云班课上考试的形式,在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/341/412/12
第二周360/3941/516/28
第三周701/10181/619/ 47代码量激增( ̀⌄ ́)
第四周608/13751/718/55①蹭了一节张健毅老师的Java课;②自己将数据结构课上所学的排序算法除了基数排序之外全部用C语言实现了一遍(`_´)ゞ;③本次博客史无前例的长:)
第五周1205/25801/89/64蹭了一节张健毅老师的Java课
第六周826/33391/98/72
第七周3119/64762/1113/85①蹭了一节张健毅老师的Java课;②在写了无数篇实验报告之后还写了两篇博客!!
第八周/1/1210/95
  • 计划学习时间:12小时

  • 实际学习时间:10小时

参考资料

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值