第二三週總結

20182305 2019-2020-1 《數據結構與面向對象程序設計》第2、三週學習總結

教材學習內容總結

這兩週的教材學習主要學習Java語言的數據類型和表達式,類和對象。包括如何設置變量、輸入數據,使用+鏈接字符串,對變量進行賦值、計算操,強制改變數據類型。經過使用Rondom類生成隨機數、格式化輸出。而且綜合運用這些編寫簡單的程序例如計算器、隨機程序。html

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

  • 問題1:print和println的區別;
  • 問題1解決方案:println會在輸出後自動換行,做用大體等同於print+\n,可是print後可使用\t、\r來輸出不一樣的格式。綜合使用更靈活,功能更強大。
  • 問題2:分清char和string類型使用中的區別;
  • 問題2解決方案:char爲字符型,而string爲字符串型。最大的區別在於字符串的最後有"\0"結尾。因此在使用 char = string.charAt(int)方法時,若是誤將char打成string就會由於類型不兼容而報錯。
  • 問題3:不理解類與方法之間的關係;
  • 問題3解決方案:經過查詢資料和閱讀教科書,我漸漸理解了類與方法間的包含關係,也明白了調用類中方法的途徑(例如:Math.PI、Die.roll);

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

  • 問題1:在作書上題的時候出現除法運算後輸出結果缺乏小數部分的錯誤。
  • 問題1解決方案:檢查後發現是我將aver = (float)(a+b+c)/ 3 ;錯寫成 aver = (float)((a+b+c)/3);致使輸出結果小數位全爲0而不是正確結果。
  • 問題2:使用Scanner類輸入數據時發生錯誤,提示InputMismatchException。
  • 問題2解決方案:原來是輸入類型與方法不匹配,將輸入語句修改爲與變量類型對應的便可。
  • 問題3:在作書上題PP3.1時,編譯發生報錯:
  • 問題3解決方法::變量b爲char型爲字符型,而a爲string型爲字符串型。區別在於字符串的最後有"\0"結尾,而字符型沒有,因此charAt時只返回一個字符並不知足字符串以"\0"結尾的定義,因而乎就會出錯。

代碼託管

上週考試錯題總結

  • 錯題一:The word println is a(n) (單詞println是一個)

A . method (方法)git

B . reserved word (保留字)編程

C . variable (變量)數據結構

D . class (類)dom

E . String (字符串)學習

  • 緣由:println是System.out.中的一個方法,而不是一個保留字。因此這題選A而不是E。
  • 錯題二:What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? (若是x和y是int類型的數值,x=10,y=5,那麼語句System.out.println(x+y);的輸出是什麼?)

A . 15插件

B . 105設計

C . 10 5調試

D . x+yhtm

E . An error since neither x nor y is a String (因x和y都不是字符串而引發的一個錯誤)

  • 緣由只有當println後括號裏有雙引號包括的字符串,即輸出字符串時使用+纔會將數據類型從數字自動轉換爲字符串輸出。如今括號裏沒有字符串,直接輸出x+y的計算結果, =15。
  • 錯題三:
    If you want to store into the String name the value "George Bush", you would do which statement? (若是你想把"George Bush"這個值存儲爲字符串類型的名字,你會執行那條語句?)

A . String name = "George Bush";

B . String name = new String("George Bush");

C . String name = "George" + " " + "Bush";

D . String name = new String("George" + " " + "Bush");

E . Any of the above would work (上述均可以完成)

  • 緣由,仔細看書以後就會發現,這些定義方法最後的結果實際上是同樣的。只是操做上略有簡繁區別。
  • 錯題四:What value will z have if we execute the following assignment statement?
    int z = 50 / 10.00; (若是咱們執行下面的賦值語句,z將獲得什麼值?)

A . 5

B . 5.0

C . 50

D . 10

E . none of the above, a run-time error arises because z is an int and 50 / 10.00 is not (以上皆錯,因z是一個整型數而50 / 10.00不是,會產生運行時錯誤)

  • 緣由:50/10.00的結果爲小數,而z的數據類型爲整形,沒法保存小數。
  • 錯題五:In order to create a constant, you would use which of the following Java reserved words? (爲了建立一個常量,你會使用下列Java保留字中的哪個?)

A . private

B . static

C . int

D . final

E . class

  • 緣由 :使用final建立的變量在整個程序運行過程當中沒法被更改,更有利於程序穩定運行。
  • 錯題六:Java is a strongly typed language. What is meant by "strongly typed"? (Java是一種強類型語言。「強類型」指的是什麼?)

A . Every variable must have an associated type before you can use it (在使用變量以前,每一個變量必定都有一個與之關聯的類型)

B . Variables can be used without declaring their type (變量能夠在不聲明其類型的狀況下使用)

C . Every variable has a single type associated with it throughout its existence in the program, and the variable can only store values of that type (在程序中,每一個變量都有一個與之關聯的類型,而變量只能存儲該類型的值)

D . Variables are allowed to change type during their existence in the program as long as the value it currently stores is of the type it is currently declared to be (變量存在於程序中時容許改變類型,只要它當前存儲的值是當前聲明的類型)

E . Variables are allowed to change types during their existence in the program but only if the change is to a narrower type (變量存在於程序中時容許改變類型,但只能縮窄轉換)

  • 錯題七:A variable of type boolean will store either a 0 or a 1. (Boolean類型的變量將被存儲爲0或1)

A . true

B . false

  • 緣由:在Java中,Boolean變量只有兩個值:true、false,而不是0、1.
  • 錯題八:Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?

A . if (x > 0) x++;

else x--;

B . if (x > 0) x++;

else if (x < 0) x--;

C . if (x > 0) x++;

if (x < 0) x--;

else x = 0;

D . if (x == 0) x = 0;

else x++;

x--;

E . x++;

x--;

  • 緣由:由於語言問題,沒能準確理解題意。
  • 錯題九:In order to compare int, float and double variables, you can use <, >, ==, !=, <=, >=, but to compare char and String variables, you must use compareTo( ), equals( ) and equalsIgnoreCase( ).

A . true

B . false

  • 緣由:對於字符型比較可使用 > , < , == 等符號,可是對於字符串的比較只能用compare()這樣的方法。

## 結對學習同窗博客(20182327)

  • 博客中值得學習的或問題:
    • 分點分章節總結學習內容,全面、真實的寫出了本身這兩週的學習狀況。
    • 添加了大量圖片,這樣有助於記錄本身的學習過程、代碼出錯的狀況,便於後續學習糾錯總結。也能夠更好的總結這一週的學習狀況。
  • 代碼中值得學習的或問題:
    • 添加的插件能夠自動生成文件頭,很方便。
  • 基於評分標準,我給本博客打分:11分。得分狀況以下:正確使用Markdown語法+1.教材學習中的問題和解決過程+2.代碼調試中的問題和解決過程+2.感想,體會不假大空+1.錯題學習深刻+1.點評認真,能指出博客和代碼中的問題+1.結對學習狀況真實可信+1.課後題有驗證+1,進度條有記錄+1.

點評過的同窗博客和代碼


學習進度條

代碼行數(新增/累積) 博客量(新增/累積) 學習時間(新增/累積) 重要成長
目標 10000行 30篇 400小時
第一週 200/200 2/2 17/17
第2、三週 556/756 3/5 31/48 明白了類與方法的關係,對Java編程的思想的瞭解有了一些進步
  • 計劃學習時間:35小時

  • 實際學習時間:31小時

相關文章
相關標籤/搜索