作者zanyking (遥远的旅人)
站内Programming
标题Re: [问题] 外国高级工程师的面试题
时间Tue Nov 17 14:44:16 2009
没学过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
1F:推 senjor:第一题的解释,其实对.net来说是没关系的140.138.155.215 11/17 20:38
2F:推 bobhsiao:第1题我觉得错在 会把字串串起来而非总和 219.85.82.131 11/17 22:33
3F:→ yauhh:第一题程式内外看起来,本来就是求字串 218.160.214.23 11/17 22:51
4F:→ dcam:第一题这样写是直觉的做法, 效率本来就不该是 220.133.198.77 11/17 23:09
5F:推 senjor:第一题就算用stringbuilder的效率也是一样140.138.155.215 11/18 15:16
6F:推 Huangs:第一题最後字串会很长喔 218.167.4.208 11/18 19:18
7F:→ Huangs:只开 char[85000] 不够吧? @@ 218.167.4.208 11/18 19:19
8F:→ yauhh:对啊,那数字起码是(1+85000)*85000/2 218.160.214.23 11/18 21:28