1. 程式人生 > >20172315 2017-2018-2 《程序設計與數據結構》第四周學習總結

20172315 2017-2018-2 《程序設計與數據結構》第四周學習總結

AD man 實例 side rand 參考資料 allow bject 編譯

20172315 2017-2018-2 《程序設計與數據結構》第四周學習總結

教材學習內容總結

第四章主要介紹了關於編寫方面的一些問題

  • 介紹了類型與對象之間的關系
  • 通過例題等介紹了怎樣編寫一個屬於自己的一個類和如何使用它
  • 介紹了實例數據和UML圖的概念
  • 在封裝一節,我學習到了如何對自己程序中的一些東西進行封裝,並知道了如何讀取和修改它
  • 學習了return語句相關的知識
    第七章主要討論了面向對象軟件的設計方法
  • 了解了靜態類相關的知識,其中包括靜態變量與靜態方法
  • 知道了類間的各種關系,包括依賴、聚合和繼承關系
  • 學習了接口的相關知識
  • 在測試一節,學習了各種軟件測試方法及其必要性

    教材學習中的問題和解決過程

  • 問題1:對於封裝的訪問器與修改器的具體使用方法不是很清楚
  • 問題1解決方案:通過看書上4.1和4.2等例題後知道了set和get如何使用
  • 問題2:關於接口的使用仍有點懵
  • 問題2解決方案:通過百度找到了一張圖便於理解
    技術分享圖片

代碼調試中的問題和解決過程

  • 問題1:在編寫pp4.5時出現了下面的錯誤
    技術分享圖片

  • 問題1解決方案:查閱資料後知道空值無法轉換成int,我把出場日期隨意初始化了一個整數,問題得以解決。
  • 問題2:在編譯pp4.5時發現以下錯誤
    技術分享圖片

  • 問題2解決方案:大部分都是打字時打錯或漏字,還有個是賦予int值時使用了引號,導致無法賦予,最後去掉引號問題得以解決。

代碼托管

技術分享圖片

(statistics.sh腳本的運行結果截圖)

上周考試錯題總結

  • 錯題1
    In Java a variable may contain
    A . a value or a reference
    B . a package
    C . a method
    D . a class
    E . any of the above
    java變量包含的值或引用類的實例
  • 錯題2
    If two variables contain aliases of the same object then
    A . the object may be modified using either alias
    B . the object cannot be modified unless there‘s but a single reference to it
    C . a third alias is created if/when the object is modified
    D . the object will become an "orphan" if both variables are set to null
    E . answers A and D are correct
    根據定義,別名提供了一種可以修改對象的方法(別名就像指針)。根據定義,別名提供了一種可以修改對象的方法(別名就像指針)。如果這兩個變量被設置為null,那麽對象不被任何變量引用(通過任何別名),它實際上變成了一個“孤兒”,將來在某個時候它會被垃圾收集。
  • 錯題3
    What is the function of the dot operator?
    A . It serves to separate the integer portion from the fractional portion of a floating point number
    B . It allows one to access the data within an object when given a reference to the object
    C . It allows one to invoke a method within an object when given a reference to the object
    D . It is used to terminate commands (much as a period terminates a sentence in English)
    E . Both B and C are correct
    點運算符在對象引用之後直接添加,後面是需要訪問的數據或方法。在數據的情況下,訪問可用於讀或寫。在一個方法的情況下,訪問是允許一個調用方法。浮點數中的點是小數點而不是點運算符。
  • 錯題4
    Which of the following will yield a pseudorandom number in the range [ -5, +5 ) given the following:
    Random gen = new Random( );
    A . gen.nextFloat( ) * 5
    B . gen.nextFloat( ) * 10 - 5
    C . gen.nextFloat( ) * 5 - 10
    D . gen.nextInt( ) * 10 - 5
    E . gen.nextInt(10) - 5
    nextfloat產量範圍[ 0, 1偽隨機數);10產量數範圍內[ 0, 10倍);減去5的產量數字範圍在【5, 5)。
  • 錯題5
    Consider the following two lines of code. What can you say about s1 and s2?
    String s1 = "testing" + "123";
    String s2 = new String("testing 123");
    A . s1 and s2 are both references to the same String object
    B . the line declaring s2 is legal Java; the line declaring s1 will produce a syntax error
    C . s1 and s2 are both references to different String objects
    D . s1 and s2 will compare "equal"
    E . none of the above
    雙方的聲明是合法的java。S1是一個字符串,它被初始化為字符串“testing123”。S2是一個字符串引用,它被初始化為字符串“測試123”。註意“測試”和“123”之間的空格。所以這兩個字符串不相等。

學習進度條

代碼行數(新增/累積) 博客量(新增/累積) 學習時間(新增/累積) 重要成長
目標 5000行 30篇 400小時
第四周 900/1600 2/9 30/90

參考資料

  • 《Java程序設計與數據結構教程(第三版)》

  • 藍墨雲

20172315 2017-2018-2 《程序設計與數據結構》第四周學習總結