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

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

第一周 add 信息 mpi use 構造函數 其中 ror 誤差

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

教材學習內容總結

這周內容多,要學習兩章的內容,實例主要是第四章的Die和Accont類以及第七章的RationNumber,Student,Address,Question類等

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

  • 問題1:對於toString不理解
  • 問題1解決方案:發現這個方法與用println顯示是緊密相連的,定義一個toString方法可以讓println方法顯示所定義對象想要的信息
  • 問題2:對RationNumber類中reduce不理解
  • 問題2解決方案:通過註釋以及結合代碼了解到reduce方法讓分數返回最簡形式

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

  • 問題1:isantique方法使用Boolean值,但對於這個值的使用方法不清楚
  • 問題1解決方案:
    技術分享圖片

  • 問題2:對於7.4中的誤差尋找不到有效的表示方法
  • 問題2解決方案:
    技術分享圖片

代碼托管

技術分享圖片

上周考試錯題總結

  • 錯題1
    The behavior of an object is defined by the object‘s
    A . instance data
    B . constructor
    C . visibility modifiers
    D . methods
    E . all of the above
    方法決定行為
  • 錯題2
    Which of the following reserved words in Java is used to create an instance of a class?
    A . class
    B . public
    C . public or private, either could be used
    D . import
    E . new
    創建實例數據需要用new
  • 錯題3
    In order to preserve encapsulation of an object, we would do all of the following except for which one?
    A . Make the instance data private
    B . Define the methods in the class to access and manipulate the instance data
    C . Make the methods of the class public
    D . Make the class final
    E . All of the above preserve encapsulation
    保留的單詞“final”用於控制繼承,與封裝沒有任何關系。
  • 錯題4
    Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?
    A . m1
    B . m2
    C . m3
    D . m5
    E . main
    一旦方法終止,控制就會使用調用該方法的方法恢復。在這種情況下,m2調用m4,因此當m4終止時,m2恢復。
  • 錯題5
    Instance data for a Java class
    A . are limited to primitive types (e.g., int, float, char)
    B . are limited to Strings
    C . are limited to objects(e.g., Strings, classes defined by other programmers)
    D . may be primitive types or objects, but objects must be defined to be private
    E . may be primitive types or objects
    實例數據是組成該類的實體,可能是任何可用的類型,無論是原始的還是對象的,可能是公有的還是私有的。通過使用對象作為實例數據,它允許將類構建在其他類之上。這種關系中,類擁有其他類的實例數據,稱為has-a關系。
  • 錯題6
    Consider a Rational class designed to represent rational numbers as a pair of int‘s, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int‘s), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.
    A . Because they will never be used
    B . Because they will only be called from methods inside of Rational
    C . Because they will only be called from the constructor of Rational
    D . Because they do not use any of Rational‘s instance data
    E . Because it is a typo and they should be declared as public
    reduce方法調用gcd方法,其中一個方法是從構造函數以外的方法調用的。
  • 錯題7
    What happens if you declare a class constructor to have a void return type?
    A . You‘ll likely receive a syntax error
    B . The program will compile with a warning, but you‘ll get a runtime error
    C . There‘s nothing wrong with declaring a constructor to be void
    D . The class‘ default constructor will be used instead of the one you‘re declaring
    E . None of the above
    聲明構造函數的任何類型都是無效的
  • 錯題8
    Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { ... }
    A . true
    B . false
    所有的Java方法都返回一個單項

其他(感悟、思考等,可選)

學習兩章任務艱巨,不能像往常那樣很輕松的完成任務,因此必須合理分配時間完成作業

學習進度條

代碼行數(新增/累積) 博客量(新增/累積) 學習時間(新增/累積) 重要成長
目標 5000行 30篇 400小時
第一周 128/128 1/1 12/12
第二周 212/340 1/2 18/30
第三周 206/546 1/3 20/50
第四周 483/1029 2/5 40/90

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