Interview Tips Interview Tips, Interview Questions and Answers

7May/110

Are C# destructors the same as C++ destructors?

No. They look the same but they are very different. The C# destructor syntax (with the familiar ~ character) is just syntactic sugar for an override of the System.Object Finalize method. This Finalize method is called by the garbage collector when it determines that an object is no longer referenced, before it frees the memory associated with the object. So far this sounds like a C++ destructor. The difference is that the garbage collector makes no guarantees about when this procedure happens. Indeed, the algorithm employed by the CLR garbage collector means that it may be a long time after the application has finished with the object. This lack of certainty is often termed ‘non-deterministic finalization’, and it means that C# destructors are not suitable for releasing scarce resources such as database connections, file handles etc.To achieve deterministic destruction, a class must offer a method to be used for the purpose. The standard approach is for the class to implement the IDisposable interface. The user of the object must call the Dispose() method when it has finished with the object. C# offers the ‘using’ construct to make this easier.

30Apr/110

What is viewstate in ASP.NET?

The postback question is the heart of any interview on ASP NET. When a postback happens (i.e. when a form is submitted to a server), the variable values that are set in the code-behind page are erased from the memory of the client system. This concept would be different from what happens in Windows-based applications, where the variable variables persist in memory until they are freed from the memory either by the garbage collector, or by specific codes like dispose or finalize.

In web applications, variable values simply get erased. But it is very simple to persist these values. They may be persisted using the Viewstate object. Before the postback is invoked, the variable's value is saved in a viewstate object. In the recieving page, the viewstate's value may be retrieved back. See example code below...

//Save the value in ViewState object before the PostBack
ViewState("SomeVar") = txtFirstName.text;

//Retrieve the value from ViewState object after the PostBack
String strFirstName = ViewState("SomeVar").ToString();

16Sep/100

Define LeaseTime, SponsorshipTime, RenewOnCallTime, LeaseManagePollTime in .NET

Terms related to lifecycle of a remoting object.

The LeaseTime property protects the object so that the garbage collector does not destroy it as remoting objects are beyond the scope of the garbage collector. Every object created has a default leasetime for which it will be activated. Once the leasetime expires, the object is eligible again for garbage collector and is eventually destroyed. Default value is 5 minutes.

Even though the leasetime of an object has expired, there still may be clients who would still need the remoting object on the server. In such cases the leasemanager keeps a track of such clients and asks them if they need the object and are ready to extend or sponsor the object to extend its existence. This is done through SponsorshipTime property, which is then based on the sponsor.

The RenewOnCallTime property defines the duration for which a remoting object's lease is extended if a sponsor is found. The default value is 2 minutes.

The LeaseManager class has a property PollTime, which defines the frequency at which the LeaseManager polls the leases. Default is 10 seconds.

11Mar/100

Interview Question :: garbage collector in .NET?

When should you call the garbage collector in .NET?

Garbage collection is a process of releasing the memory used by the objects, which are no longer referenced. This is done in  different ways and different manners in various platforms and languages. We will see how garbage collection is being done in .NET.

21Dec/090

What A Mid-Level .NET Developers Ought To Know

continue http://tipsinterview.com/2009/12/21/what-every-net-developers-ought-to-know/ 

    1. Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
    2. Describe what an Interface is and how it’s different from a Class.
    3. What is Reflection?
    4. What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
    5. Are the type system represented by XmlSchema and the CLS isomorphic?
    6. Conceptually, what is the difference between early-binding and late-binding?
    7. Is using Assembly.Load a static reference or dynamic reference?
    8. When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
    9. What is an Asssembly Qualified Name? Is it a filename? How is it different?
    10. Is this valid? Assembly.Load("foo.dll");
    11. How is a strongly-named assembly different from one that isn’t strongly-named?
    12. Can DateTimes be null?
    13. What is the JIT? What is NGEN? What are limitations and benefits of each?
    14. How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
    15. What is the difference between Finalize() and Dispose()?
    16. How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
    17. What does this useful command line do? tasklist /m "mscor*"
    18. What is the difference between in-proc and out-of-proc?
    19. What technology enables out-of-proc communication in .NET?
    20. When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?