20155317 2016-2017-2 《Java程序設計》第7周學習總結

20155317 2016-2017-2 《Java程序設計》第7周學習總結

教材學習內容總結

1.在只有Lambda表達式的狀況下,參數的類型必須寫出來。html

2.Lambda表達式自己是中性的,一樣的Lambda表達式可用來表示不一樣目標類型的對象操做。java

3.Lambda表達式只關心方法命名上的參數與返回定義,但忽略方法名稱。git

4.若是變量不會在匿名類中有從新指定的動做,就能夠不用加上final關鍵詞。 5.只要靜態方法的方法命名中參數與返回值定義相同,也可使用靜態方法來定義函數接口操做。express

6.JDK8定義的通用函數接口,基本上放置於java.util.function套件之中,就行爲來講,基本上能夠分爲consumer,function,predicate,supplier四個類型。swift

7.Epoch爲某個特定時代的開始,時間軸上某一瞬間。markdown

8.取得系統時間的方法之一是使用System,currentTimeMillis()方法,返回的是long類型整數。app

9.Date實例基本上建議只用來當作時間軸上的某一瞬間。函數

10.ofDays(),ofMonths(),ofWeeks()實際上是Period的靜態方法,他們會返回period實例。oop

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小時

  • 改進狀況:

(有空多看看現代軟件工程 課件 軟件工程師能力自我評價表)

參考資料

相關文章
相關標籤/搜索