Re: [問題] 外國高級工程師的面試題

看板Programming作者 (遙遠的旅人)時間16年前 (2009/11/17 14:44), 編輯推噓4(404)
留言8則, 5人參與, 最新討論串2/3 (看更多)
沒學過ASP.NET ※ 引述《zuki326 (Zukisa)》之銘言: : 這裡有一份外國公司的高級工程師面試題 : 不知道有沒有人可以答得出來 : 1. Explain in detail what is wrong with the following code-block : and provide a correct implementation: : 解釋以下程式碼有何錯誤,並提供正確的寫法 : private string GetString() : { : string value = string.Empty; : for (int i = 0; i < 85000; i++) : value += i.ToString(); : return value; : } 因為String 在語言設計上通常都是 immutable 的,所以String + operator 每次操作都得產生新的String才行,而上面的程式裡每次for loop產生出來的 新String除了給下次用以外沒有其他用途。這是一種可怕的浪費。 我想到的解法是給new char[85000] ,塞數字,然後語言本身一定有方法可以 直接轉String。 : 2. What is the significance of the value 85000 in the code-block above? : (hint: 85,000 bytes and Memory Allocation/Garbage Collection) : 上題中的 85000 有什麼特別的意義? : (提示: 85,000 bytes and Memory Allocation/Garbage Collection ) 這題考Google的能力嗎? 我還沒查之前猜大概是微軟的什麼系統結構會對大到一定程度的物件做不一樣的 什麼處理吧? 查完好像也是這樣。 : 3. You have the following ASP.NET code-behind class: : 你有以下的 ASP.NET 程式碼 : public partial class Page1 : Page : { : private string _value; : public Page1() : { : if (DateTime.Now.Ticks % 10 == 0) : _value = "Test"; : } : ~Page1() : { : if(_value.Equals("Test")) : _value = string.Empty; : } : } : You have found events in the Application event log indicating : that the ASP.NET worker process is crashing. : You determine the problem to be that in some circumstances, : accessing _value throws a NullReferenceException. : Why does this crash the ASP.NET worker process instead of showing an error : to the end-user? : 你發現 Application event log 紀錄 ASP.NET 的 process 會出現錯誤。 : 你發現問題出在某些情況下 accessing _value throws a NullReferenceException。 : 為什麼這個ASP.NET 程式在出錯時會 crash 而不是向用戶顯示錯誤訊息? 我猜deconstructor 爆炸當然就是記憶體管理已經不行了。 對.NET Framework來說,這有可能會是執行Unmanaged 記憶體回收發生異常,造成 記憶體滲漏的問題。所以它會直接terminate process. (應該改寫成"Test".equals(_value)才對) : 4. You have identified that your ASP.NET worker process is consuming : large amounts of memory and is not releasing it. : How would you identify whether it is a native memory leak or : an issue with managed code? If you identified the issue as a problem : with managed code, what steps would you take to further isolate the issue? : (這題真不知道怎麼翻…) 不熟.NET Framework,不過通用的作法是:縮小『可能造成Memory leak』的範圍 : 5. Provide a comparison of XML and JSON including the pros and : cons of each and provide ideal uses for both. : 提出 XML 與 JSON 的對比,包括雙方的優缺點列表。 XML PROs: 元素自由度較高、支援CDADA、很多中介服務都直接支援。 XML CONS: 語法囉唆,傳輸上花很多無謂的字元。 Javascript處理時得要Parsing,W3CDOM API難用。 額外的Parsing處理要花時間與處理效能。 JSON PROs: 簡單、乾淨、Browser對多數的Script Language(特別是Javascript)可直接作為 資料結構使用。 JSON CONs: 離開Web的世界就沒有太大的通用性。 : 6. Discuss some common rendering issues with Internet Explorer : (version of your choice) and provide some workarounds. : Internet Explorer (任何版本) 有哪些呈現上的問題,並提出要如何解決。 IE6,全部都有問題。 Javascript效能太差、安全性漏洞百出、頁面用久了還有記憶體滲漏。 升級IE8,把他換掉。 : 7. Provide a comparison of the box model in Internet Explorer 5.5 : and Internet Explorer 7.0 : 提出 Internet Explorer 5.5 與 Internet Explorer 7.0 中的 box model 的比對。 : 8. As an ASP.NET developer, how to you see Silverlight 2.0 fitting : into the development of web applications? : 作為一個 ASPNET 的工程師,你對於在網頁軟體開發中使用 Silverlight 2.0 : 有什麼看法。 看法就跟把Flash放到JSP還是PHP一樣。 除非你要搞2D Graphic Animation、Media Streaming以及沒有SEO需求的Web APP, 不然別用。 : 9. Explain why using CSS image replacement techniques (image sprites) : has better perceived performance than using individual images. : 解釋為什麼用 CSS 圖片替換技術 (image sprites) 會比用單獨的圖片有更好的效果。 節省無謂的傳輸次數、圖片不閃爍、圖片有可能可再不同的區塊重用。 : 10. You have the following Go.gif image. : The full image dimensions are 75x40px : 你有一個 Go.gif 圖片檔。完整的圖片大小為 75x40px : http://www.badongo.com/pic/7762055 : The HTML for this button is : 這個按鈕的 HTML 是 : <a id="lnkGo" href="#">Go</a> : a. Provide a CSS-only implementation of the button with a hover state : (the dark blue is the hover state) : 提供一個這個按鈕的 CSS-only implementation 與 hover state : (應該是說滑鼠放上去會變成深藍色的?) 給一個id selector, 然後在.Hover的時候對圖片套alpha嗎? : b. Provide an implementation that uses CSS for the initial state : but jQuery for the hover state : 提供一個使用 CSS 在最初的狀態,但是用 jQuery 在 hover state : 11. You visited an eCommerce website, and when navigating to : a Cannon SD1000 camera, you noticed the URL was : http://www.mystore.com/ViewProduct.aspx?productId=10 : 你去了一個電子商務的網站,當你到 Cannon SD1000 相機的頁面時, : 發現網址是 http://www.mystore.com/ViewProduct.aspx?productId=10 : You have been asked to consult on SEO best practices. : What recommendations would you make to the site developer with regards : to his URL’s? : 你現在是負責做這個公司的諮詢工作,你要怎麼建議這個網站的工程師改進他的網址? http://www.mystore.com/ViewProduct/10/Cannon-SD1000 把URL改成這樣,/10/後面加的產品名稱其實沒用,就是給crawler看而已。 : 12. You visited a website that has a menu composed of images. : You noticed that on mouse over of each image, the image flickers. : What would you recommend to the webmaster to prevent the flickering? : 你去了一個有很多圖片組成的menu的網站。 : 當你把滑鼠放上去的時候,每個圖案都會閃爍。 : 你要怎麼建議網站的工程是針對這個做改進? 不熟,我猜應該是image 設cache還是URL調整一下之類的。 或者,開幾個1*1px的DIV,背景圖設成沒load進來的。 或者,一個大圖片包含一堆小圖片,CSS套的時候再去算定位座標、大小、旋轉角度 把要呈現的框出來。(CSS Sprites) : 13. You are managing a website that displays a (hidden) : layer on top of a number of SELECT elements. : Some users are complaining that the dropdown list is appearing on top of : the layer. Why does this occur and how would you fix it? : 你負責管理一個網站。這個網站在一些 SELECT elements 之上有一個 (隱藏的) 層。 : 一些用戶抱怨下拉是菜單出現在這個層之上。為什麼會發生這個情況? 要如何修正? Browser native zindex 順序的問題(IE6)。 要修正可以墊一個比它偉大的(例如Iframe)在上面。 : 14. You have an unordered list with 10 elements. : The list has an ID of “myList”. Using jQuery, how would you: : 你有一個沒排序過的 10 個物件的列表。這個列表的 ID 是 “myList” : 。使用 jQuery, 你要怎麼 : a. Change the fore color of all even list items to red : 改變所有表中單數物件的顯示顏色為紅色 : b. Indent the 5th item when the mouse hovers over it : 當滑鼠放上的時候, Indent (就是前面空格?) 第五個物件 : 15. Explain some key differences between : using an ASP.NET UpdatePanel versus using either PageMethods or : web services to retrieve and populate data. : 解釋使用 ASP.NET UpdatePanel 及使用 PageMethods 或 web services 來獲取及顯示數據的主要區別 : 16. Discuss a new features of ASP.NET 3.5 Service Pack 1. : ASP.NET 3.5 Service Pack 1 中有哪些新的功能 以上不熟,沒用過。 : 17. Discuss in detail a technique, as it relates to web development, : that you frequently use and feel would be beneficial : to share to a new development team. : 解釋你在網站開發中較常使用,且覺得有分享給開發團隊的價值的技術 哈哈,看來我還差很遠。 -- 我所信仰的科學是一種謙卑的理性,承認自身的無知與渺小才能觀察到世界在我們貧 弱的知覺上留下來的痕跡。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.44.37

11/17 20:38, , 1F
第一題的解釋,其實對.net來說是沒關係的
11/17 20:38, 1F

11/17 22:33, , 2F
第1題我覺得錯在 會把字串串起來而非總和
11/17 22:33, 2F

11/17 22:51, , 3F
第一題程式內外看起來,本來就是求字串
11/17 22:51, 3F

11/17 23:09, , 4F
第一題這樣寫是直覺的做法, 效率本來就不該是
11/17 23:09, 4F

11/18 15:16, , 5F
第一題就算用stringbuilder的效率也是一樣
11/18 15:16, 5F

11/18 19:18, , 6F
第一題最後字串會很長喔
11/18 19:18, 6F

11/18 19:19, , 7F
只開 char[85000] 不夠吧? @@
11/18 19:19, 7F

11/18 21:28, , 8F
對啊,那數字起碼是(1+85000)*85000/2
11/18 21:28, 8F
文章代碼(AID): #1B0aP3Uy (Programming)
討論串 (同標題文章)
文章代碼(AID): #1B0aP3Uy (Programming)