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

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

教材学习内容总结

1.在只有Lambda表达式的情况下,参数的类型必须写出来。

2.Lambda表达式本身是中性的,同样的Lambda表达式可用来表示不同目标类型的对象操作。

3.Lambda表达式只关心方法命名上的参数与返回定义,但忽略方法名称。

4.如果变量不会在匿名类中有重新指定的动作,就可以不用加上final关键词。 5.只要静态方法的方法命名中参数与返回值定义相同,也可以使用静态方法来定义函数接口操作。

6.JDK8定义的通用函数接口,基本上放置于java.util.function套件之中,就行为来说,基本上可以分为consumer,function,predicate,supplier四个类型。

7.Epoch为某个特定时代的开始,时间轴上某一瞬间。

8.取得系统时间的方法之一是使用System,currentTimeMillis()方法,返回的是long类型整数。

9.Date实例基本上建议只用来当做时间轴上的某一瞬间。

10.ofDays(),ofMonths(),ofWeeks()其实是Period的静态方法,他们会返回period实例。

11.新时间日期处理API的主要套件命名为java.time。

12.plus方法接受java.time.temporal.TemporalAmount实例,而TemporalAmount的操作类也就是Period与Duration。实际上plus()方法也可以接受Duration实例来计算。

13.使用Instant的静态方法now()可以取得代表java epoch毫秒数的Instant实例。

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

  • SimpleDateFormat还有个parse()方法,可以按构建SimpleDateFormat时指定的格式,将指定的字符串剖析为Date实例。如:
  • import java.util.*;
    import java.text.*;
    
    public class HowOld {
        public static void main(String[] args) throws Exception {
            System.out.print("輸入出生年月日(yyyy-mm-dd):");
            DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
            Date birthDate = dateFormat.parse(new Scanner(System.in).nextLine());
            Date currentDate = new Date();
            long life = currentDate.getTime() - birthDate.getTime();
            System.out.println("你今年的歲數為:" + 
                      (life / (365 * 24 * 60 * 60 * 1000L)));
        }
    }

     

  • Calendar是个抽象类,java.util.GregorianCalendar是其子类,操作了儒略历与格里高利历的混合历,通过Calendar的getInstance()取得的Calendar实例,默认就是取得GregorianCalendar实例。如:
  • out.println(calendar.get(Calendar.YEAR));
    out.println(calendar.get(Calendar.MONTH));
    out.println(calendar.get(Calendar.DATE));

     

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

  • 在这个程序中,我明明是19周岁,却被误算为20周岁
  •  

  • 问题2:XXXXXX
  • 问题2解决方案:XXXXXX
  • ...

代码托管

 

上周考试错题总结

    • 调用线程的interrupt()方法 ,会抛出()异常对象?
      A .
      IOException
      B .
      IllegalStateException
      C .
      RuntimeException
      D .
      InterruptedException
      E .
      SecurityException
      正确答案: D E

    • 现有
    1. class Calc {
    2. public static void main(String [] args) {
    3. try {
    4.     int x = Integer.parselnt ("42a") ;
    5. //insert code here
    6.     System.out.print ("oops");
    7. }
    8. }
    9. }
      下面哪行分别插入到第五行,会导致输 "oops" ?
      A .
      catch (IllegalArgumentException e) {

    B .
    } catch (IllegalStateException c) {

    C .
    } catch (NumbelFormatException n) {

    D .
    } catch (ClassCastException c) {

    正确答案: A C

    • Given an instance of a Stream, s, and a Collection, c, which are valid ways of creating a parallel stream? (Choose all that apply.)
      给定一个Stream的实例s, 一个Collection的实例c, 下面哪些选项可以创建一个并行流?

    A .
    new ParallelStream(s)
    B .
    c.parallel()
    C .
    s.parallelStream()
    D .
    c.parallelStream()
    E .
    new ParallelStream(c)
    F .
    s.parallel()
    正确答案: D F

    • Which of the following statements about the Callable call() and Runnable run() methods are correct? (Choose all that apply.)
      A .
      Both can throw unchecked exceptions.
      B .
      Callable takes a generic method argument.
      C .
      Callable can throw a checked exception.
      D .
      Both can be implemented with lambda expressions.
      E .
      Runnable returns a generic type.
      F .
      Callable returns a generic type.
      G .
      Both methods return void
      正确答案: A C D F

    • What are some reasons to use a character stream, such as Reader/Writer, over a byte stream, such as InputStream/OutputStream? (Choose all that apply.)

    A .
    More convenient code syntax when working with String data

    B .
    Improved performance

    C .
    Automatic character encoding

    D .
    Built-in serialization and deserialization

    E .
    Character streams are high-level streams

    F .
    Multi-threading support

    正确答案: A C

    • Assuming zoo-data.txt is a multiline text file, what is true of the following method?
      private void echo() throws IOException {
      try (FileReader fileReader = new FileReader("zoo-data.txt");
      BufferedReader bufferedReader = new BufferedReader(fileReader)) {
      System.out.println(bufferedReader.readLine());
      }
      }

    A .
    It prints the first line of the file to the console.

    B .
    It prints the entire contents of the file.

    C .
    The code does not compile because the reader is not closed.

    D .
    The code does compile, but the reader is not closed.

    E .
    The code does not compile for another reason.

    正确答案: A 你的答案

    • What is the result of executing the following code? (Choose all that apply.)
      String line;
      Console c = System.console();
      Writer w = c.writer();
      if ((line = c.readLine()) != null)
      w.append(line);
      w.flush();

    A .
    The code runs without error but prints nothing.

    B .
    The code prints what was entered by the user.

    C .
    An ArrayIndexOutOfBoundsException might be thrown.

    D .
    A NullPointerException might be thrown.

    E .
    An IOException might be thrown.

    F .
    The code does not compile.

    正确答案: B D E

    • Which of the following are true? (Choose all that apply.)

    A .
    A new Console object is created every time System.console() is called.

    B .
    Console can only be used for reading input and not writing output.

    C .
    Console is obtained using the singleton pattern.

    D .
    When getting a Console object, it might be null.

    E .
    When getting a Console object, it will never be null.

    正确答案: C D

    • Suppose that the file c:\book\java exists. Which of the following lines of code creates an object that represents the file? (Choose all that apply.)

    A .
    new File("c:\book\java");

    B .
    new File("c:\book\java");

    C .
    new File("c:/book/java");

    D .
    new File("c://book//java");

    E .
    None of the above

    正确答案: B C

    • Which of the following are built-in streams in Java? (Choose all that apply.)

    A .
    System.err

    B .
    System.error

    C .
    System.in

    D .
    System.input

    E .
    System.out

    F .
    System.output

    正确答案: A C E

结对及互评

评分标准

  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语言实现时间与日期的输出。用书上的代码练习之后,对内容的了解更加深入。

学习进度条

 代码行数(新增/累积)博客量(新增/累积)学习时间(新增/累积)重要成长
目标 5000行 30篇 400小时  
第一周 200/200 2/2 20/20  
第二周 300/500 2/4 18/38  
第三周 500/1000 3/7 22/60  
第四周 300/1300 2/9 30/90  
第五周 300/1300 2/9 30/90  
第六周 543/1300 2/9 30/90  
第七周   

尝试一下记录「计划学习时间」和「实际学习时间」,到期末看看能不能改进自己的计划能力。这个工作学习中很重要,也很有用。 耗时估计的公式 :Y=X+X/N ,Y=X-X/N,训练次数多了,X、Y就接近了。

参考:软件工程软件的估计为什么这么难软件工程 估计方法

  • 计划学习时间:XX小时

  • 实际学习时间:XX小时

  • 改进情况:

(有空多看看现代软件工程 课件 软件工程师能力自我评价表)

参考资料

posted @ 2017-04-08 19:22  20155317wxw  阅读(160)  评论(4编辑  收藏  举报