23題跟24題是設計概念上的問題
雖然不是語法邏輯之類的問題,但是重要性也不能忽視
設計規劃有如藍圖,撰寫程式有如鋼筋水泥
藍圖如果不好,即使用上好的建材也造不出好房子;程式規劃沒做好,也難以寫出好的程式,也會使維護更加困難
第二十一題: |
Given: class Batman { |
What is the result? A. 81 |
答案:B |
執行結果:答案中 |
題目範圍:基本觀念 |
解析: 變數的區域性要注意,這題其實不難,但是針對物件的概念再加以解說一下 |
第二十二題: |
Given: class Pass { |
What is the result? A. Compilation fails. |
答案:D |
執行結果:答案中 |
題目範圍:基本觀念 |
解析: JAVA中沒有指標的語法,不過有時還是隱藏了指標的用法 x++是先執行完指令再累加;++x是先累加在完成指令 |
第二十三題: |
A company has a business application that provides its users with many different reports: receivables reports, payables reports, revenue projects, and so on. The company has just purchased some new, state-of-the-art, wireless printers, and a programmer has been assigned the task of enhancing all of the reports to use not only the company's old printers, but the new wireless printers as well. When the programmer starts looking into the application, the programmer discovers that because of the design of the application, it is necessary to make changes to each report to support the new printers. Which two design concepts most likely explain the situation? A. Inheritance |
答案:BC |
執行結果:無 |
題目範圍:物件觀念 |
解析: 這題直接舉了一個例子:工程師發現程式要更新時,他必須修改所有的報表產生器內容 為什麼會導致必須修改所有的報表產生器來維護這個軟體呢?推測起來就是因為所有的報表產生時都是獨立運作的,應收帳款報表、應付帳款報表、收入報表等等都完全是由不同的程式片段來產生,類似的工作,卻是由全然不同的程式片段來執行,這就是低度的分工,Low cohesion 獨立產生報表的同時也會出現一個問題,那就是添購新的印表機時,必須逐一修改程式片段;這也表示程式在運作時,程式片段會有很多資料交換,這就是高度的耦合,Tight coupling 雖然這裡舉出了這樣的例子,不過不要誤會,cohesion 和coupling 的高低沒有絕對的關係,不是高度的分工就一定會是低度的耦合 請參閱:第二十題 |
第二十四題: |
A company that makes Computer Assisted Design(CAD) software has, within its application some utility classes that are used to perform 3D rendering tasks. The company's chief scientist has just improved the performance of one of the utility classes' key rendering algorithms, and has assigned a programmer to replace the old algorithm with the new algorithm. When the programmer begins researching the utility classes, she is happy to discover that the algorithm to be replaced exists in only one class. The programmer reviews that class's API, and replaces the old algorithm with the new algorithm, being careful that her changes adhere strictly to the class's API. Once testing has begun, the programmer discovers that other classes that use the class she changed are no longer working properly. What design flaw is most likely the cause of there new bugs? A. Inheritance |
答案:B 感謝mk0079提醒,已經修正於2012/02/23 |
執行結果:無 |
題目範圍:物件觀念 |
解析: 這個例子裏面有提到,工程師在修改時只需要針對功能做小部分的修改,這是高度的分工 程式之間的資料交流有太多多餘的部分,就很容易出現這種高度耦合問題
高耦合:A丟出整數小數字串的其中一種、資料長度、資料型態給B顯示 這樣看起來,低耦合的情況,在新增程式功能時,會出現的問題就會少很多,例如加一個C程式來處理A的資料,或是要把A程式換掉 |
第二十五題: |
Given: class ClassA { |
What is the result? A. 420 is the output |
答案:A |
執行結果:答案中 |
題目範圍:物件觀念 |
解析: 建構子也是一種方法,可以使用的標記跟一般方法一樣 |
留言列表