Friday, May 25, 2012

C# .Net Interview Questions


        1. Which is better - singly linked list or doubly linked list? What are the pros and cons of using each?
Answer -
 It depends on the requirement.Single linked list has smaller memory requirement because it needs only forward reference. If you need to get next item from a specified item, then you should use single list. It can be traversed in forward direction only.

When you need to get previous or next item from a specified item then doubly linked is the best option. It can be traversed in both directions.

2. What's the difference between Managed code and Native code? 
Answer - 
Managed Code - Managed code is the code which runs under .Net CLR.  CLR basically take care of Exception handling, memory management, Code access security, etc.  It is not compiled directly to machine code , but to an intermediate language.  

Native code: Code which is complied directly to machine code. It is executed by OS directly. It always has chances of memory leak if developer has not handled it properly. Unlike CLR, There is no garbage collection and no memory management.

       3. What is thread safe code?
Answer -
In multithreaded application where multiple threads call the same method of the object. Then there should be synchronization mechanism so that one thread can not interrupt other thread. If this situation is not synchronized, then one thread might interrupt another thread and the object could be left in an invalid state. A class whose members are protected from such interruptions is called thread-safe.


1 comment:

  1. very informative post indeed.. being enrolled in http://www.wiziq.com/course/6349-asp-net-interview-questions-for-freshers-2-years-experience was looking for such articles online to assist me.. and your post helped me a lot

    ReplyDelete