public
private
等。Tostring
,return
這些基礎的知識。形式參數是函數定義中的,系統沒有爲其分配內存空間,可是在定義裏面可使用的參數。例如:fun(int a)。這裏a就是形式參數。
實際參數是函數調用的時候傳給函數的變量。這個是系統實實在在分配了內存空間的變量。
簡單點說,就是形式參數給個形式,實際參數放進去用。例如:fun(a);
函數聲明的用處是告訴編譯器聲明的函數在後面有定義。若是你將函數定義放在調用的前面,就不須要聲明。另外聲明就是函數定義後面加上分號的形式。
例如:定義是fun(int a)。聲明就是fun(int a);
對於實驗的解決方法就是
html
在學習第七章找到了這種問題的解決方法:在上述構造方法中,this引用特指對象的實例變量,賦值語句右邊的變量是構造方法的形參變量。
這種方法避免了對含義相同的變量要給出不一樣命名以示區別的問題。有時,這種狀況發生在其餘的方法中,但更常常出如今構造方法中。java
toString
方法,但在return時卻一直報錯,因而我就使用了多個toString方法,發現仍是有錯誤,最後才發現能夠用「+」來拼接╥﹏╥在IDEA中想要上傳文件到碼雲,卻遇到了這個問題git
問題1解決方案:其實本身仍是不會使用IDEA來push和pull項目,有時成功有時又失敗,(╥╯^╰╥)。程序員
問題2解決方案:課本有說過,每一個類都有一個不帶參數的的默認構造方法。可是必需要實例化這個類(固然這不是惟一產生對象的途徑,好比單例模式,但本質上說全部途徑都是同樣的)的時候,那麼就要用到本身寫的構造函數,即告訴程序我如今要實例化一個對象了,你給我立刻分配內存,將內存的首地址賦給我指定的類對象。編程
問題3的解決方案:老師對這個程序進行調試時,發現其中有一項一直輸出空值,而後才發現是循環語句打錯了(尚未學循環語句)。安全
錯題一: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
正確答案: E
解析:
A.可使用別名來修改對象
B.對象不能被修改除非有一個單獨的引用
C.語言若是對象被修改,則會建立第三個別名。
D.若是兩個變量都被設爲null,那麼這個對象就會變成一個「孤兒」
E.答案A和D是正確的
解析:在課本3.1.1中有解釋,String對象一旦被建立就不可變,可是別名提供了一種能夠修改對象的方法。根據定義若是兩個變量都被設爲null,那麼這個對象就不會被任何變量引用(經過任何別名),它確實會變成一個「孤兒」,而且在未來的某個時候會被垃圾收集。數據結構
錯題二:Which properties are true of String objects?
A . Their lengths never change
B . The shortest string has zero length
C . Individual characters within a String may be changed using the replace method
D . The index of the first character in a string is one
E . Only A and B are true
正確答案: E
解析:字符串是不可變的。這意味着,一旦建立了string對象,就不能更改它。字符串的長度在建立後不會發生改變。最短的長度字符串是"",因此長度是0。replace方法容許從原來的一個字符串中建立一個新的字符串,替換一些字符。字符串中第一個位置的索引是0,而不是1。另外,每一個字符串的最後一個字節包含字符串末尾字符,它是低值或二進制0的字節。app
錯題三:What happens if you attempt to use a variable before it has been initialized?
A . A syntax error may be generated by the compiler
B . A runtime error may occur during execution
C . A "garbage" or "uninitialized" value will be used in the computation
D . A value of zero is used if a variable has not been initialized
E . Answers A and B are correct
正確答案:E
解析:不少時候,編譯器可以檢測到未初始化的變量的嘗試,在這種狀況下它會產生一個語法錯誤。若是編譯器使用逃逸檢測,則在使用時出現運行時錯誤。Java是一種很是「安全」的語言,所以,若是在計算中使用未初始化的變量,則不容許使用「垃圾」或「零」。less
錯題四:
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
正確答案: E
解析: .
點操做符直接追加在對象引用以後,後面是須要訪問的數據或方法。在數據的狀況下,訪問多是爲了閱讀或寫做。在方法的狀況下,訪問是容許某人調用該方法。浮點數中的點是一個小數點而不是一個點算符。dom
錯題五:In Java, "instantiation" means
A . noticing the first time something is used
B . creating a new object of the class
C . creating a new alias to an existing object
D . launching a method
E . none of the above
正確答案: B
你的答案: C
解析:「實例化」意味着建立對象的新實例。這一般是經過使用新操做符來完成的。在字符串的狀況下,只需在表達式中使用引號,就能夠建立新的實例(實例化)。例如:字符串年代;s="一個新字符串(實例)";
錯題六:Say you write a program that makes use of the Random class, but you fail to include an import statement for java.util.Random (or java.util.). What will happen when you attempt to compile and run your program.
A . The program won't run, but it will compile with a warning about the missing class.
B . The program won't compile-you'll receive a syntax error about the missing class.
C . The program will compile, but you'll receive a warning about the missing class.
D . The program will encounter a runtime error when it attempts to access any member of the Random class
E . none of the above
正確答案: B
你的答案: A
假設您編寫了一個程序,該程序使用了Random類,可是您沒有包含java.util的import語句,(或java.util。)。當您試圖編譯並運行您的程序時將會發生什麼。
A.這個程序不會運行,可是它將會對丟失的類發出警告。
B.程序不會編譯,您將會收到關於丟失的類的語法錯誤。
C.程序將會編譯,可是您會收到一個關於丟失的類的警告。
D.當程序試圖訪問隨機類的任何成員時,程序將會遇到運行時錯誤
E.以上都不是缺乏的類意味着將會有未定義的變量和/或方法。編譯器會檢測到這些,並會發出錯誤消息。你的程序是不可執行的。
錯因:仍是沒有準確理解編譯和進行的區別。
解析:缺乏的類意味着將會有未定義的變量和/或方法。編譯器會檢測到這些,並會發出錯誤消息。你的程序是不可執行的。
錯題七: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
正確答案: B 個人答案: E
解析:gen.nextInt(10) - 5 所獲得的結果是-5,-4,-3,-2,-1,0,1,2,3,4,並非題目中所要求的,它獲得的只是一些數而不是一個取值範圍。而nextFloat則是在範圍[0,1)中產生僞隨機數字;乘以10的收益率在0到10之間,再減去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 objects 1和s2都是對同一個字符串對象的引用
B . the line declaring s2 is legal Java; the line declaring s1 will produce a syntax error 聲明s2的行是合法的Java;聲明s1的行將產生一個語法錯誤
C . s1 and s2 are both references to different String objects s1和s2都是對不一樣字符串對象的引用
D . s1 and s2 will compare "equal" s1和s2會比較"相等"
E . none of the above
正確答案: C
你的答案: A
錯因:粗枝大葉,沒有注意到二者細微的差異。
解析:這兩個聲明都是合法的Java。s1是一個字符串引用,它被初始化爲字符串「testing123」。s2是一個字符串引用,它被初始化爲字符串「測試123」。注意「測試」和「123」之間的空格。因此這兩個字符串不相等。
錯題九:
An "alias"(別名) is when
A . two different reference variables refer to the same physical object
B . two different numeric variables refer to the same physical object
C . two different numeric variables contain identical values
D . two variables have the same names
E . none of the above
正確答案: A
你的答案: B
解析:當有兩個或多個對同一物理對象的引用時,就會出現「別名」,這樣,經過遵循任一引用,就能夠讀/寫/修改對象
錯題十:
The String class' compareTo method
A . compares two string in a case-independent manner(獨立的方式)
B . yields (收益率)true or false
C . yields 0 if the two strings are identical
D . returns 1 if the first string comes lexically before the second string
E . none of the above
正確答案: C
你的答案: E
解析:若是兩個字符串是徹底一致的,那麼它的值爲0。
錯題十一:
An API is
A . an Abstract Programming Interface(一個抽象的編程接口)
B . an Application Programmer's Interface(應用程序程序員的接口)
C . an Application Programming Interface(一個應用程序編程接口)
D . an Abstract Programmer's Interface(一個抽象的程序員的接口)
E . an Absolute Programming Interface(一個絕對的編程接口)
正確答案: C
你的答案: B
錯因:沒有理解好課本3.3.1
解析:API是一個應用程序編程接口,它是爲特定目的而構建的相關類的集合。它們一般駐留在類庫中。
錯題十二:
The advantage(s) of the Random class' pseudo-random number generators, compared to the Math.random method, is that(與數學相比,隨機類的僞隨機數生成器的優勢是隨機方法: )
A . you may create several random number generators(你能夠建立幾個隨機數生成器)
B . the generators in Random are more efficient than the one in Math.random(隨機產生的發電機比數學中的那個更有效率)
C . you can generate random ints, floats, and ints within a range(你能夠在一個範圍內生成隨機的ints、浮點數和ints)
D . you can initialize and reinitialize Random generators(您能夠初始化並從新初始化隨機生成器)
E . all but answer B
正確答案: E
你的答案: C
錯因:沒有理解題目。
解析:全部隨機數字生成器的效率是同樣的。隨機生成器優於數學的優勢。隨機包含全部其餘屬性。
錯題十三:
The advantages of the DecimalFormat class compared with the NumberFormat class include(與NumberFormat類相比,十進制格式類的優勢包括)
A . precise control over the number of digits to be displayed(精確控制要顯示的數字的數量)
B . control over the presence of a leading zero(控制一個前導零的存在)
C . the ability to truncate values rather than to round them(語言可以截斷值而不是繞過它們)
D . the ability to display a % automatically at the beginning of the display(在顯示開始時自動顯示「%」的能力)
E . only A and B
正確答案: E
你的答案: A
錯因:沒有詳細比較二者的區別
解析:雖然十進制格式提供的控制比NumberFormat要多得多,可是經過一個或多個數學方法,截斷仍然在程序員的手中「%」符號會出如今顯示器的末端,而不是開始。
代碼行數(新增/累積) | 博客量(新增/累積) | 學習時間(新增/累積) | 重要成長 | |
---|---|---|---|---|
目標 | 5000行 | 30篇 | 400小時 | |
第一週 | 127/127 | 1/1 | 25/25 | |
第二週 | 278/405 | 1/2 | 20/45 | |
第三週 | 442/847 | 1/3 | 20/65 | |
第四周 | 1063/1910 | 2/5 | 30/95 |
在學第七章的時候碰見了不少的條件語句,也遇到了不少的問題,發現就算是照着課本打,有時也會出問題,由於你根本就沒有理解這些數據的含義究竟是什麼。因此咱們的學習不僅是簡單照着書本上敲代碼,更多的是要去理解他爲何要這樣敲,要從中去總結規律,這樣才能更快更好的去掌握知識。我認爲我要努力的方面還有不少,還要儘可能去使用網上的資源,而不是僅僅只看課本。